【发布时间】:2011-03-19 10:23:55
【问题描述】:
我有一个客户端项目,我需要为某个文件夹强制使用 HTTPS,并为所有其他文件夹强制使用 HTTP。我可以成功地为我想要的文件夹强制实施 HTTPS,但所有返回站点其余部分的链接最终都通过 HTTPS。我想要一个规则,强制对安全文件夹中任何“不”的请求强制返回 HTTP。到目前为止,这是我所拥有的:
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{HTTPS} !=on
RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
'my' 是我需要为其强制使用 HTTPS 的文件夹的名称。
有什么想法吗?
更新:我也试过了:
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
# Force HTTPS for /my
RewriteCond %{HTTPS} !=on
RewriteRule ^(my) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
# Force HTTP for anything which isn't /my
RewriteCond %{HTTPS} =on
RewriteRule !^my http://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
# Remove index.php from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1
但现在它们不再通过 HTTPS 强制对 /my 的请求解析为 http://www.example.com/index.php/my
:?
【问题讨论】:
标签: apache http mod-rewrite https