【发布时间】:2011-03-02 08:44:08
【问题描述】:
出于性能原因,我试图在哪些页面/请求使用SSL 时更具选择性。我想使用htaccess 重定向到https:// 仅用于所需的页面,并重定向回http:// 用于其他所有内容。这就是我所拥有的:
RewriteEngine On
# force https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)/(abc|xyz)(.*)$ https://%{HTTP_HOST}/$1/$2 [R=301,NC,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_REFERER} !^https(.*)/(abc|xyz)(.*)$ [NC]
RewriteCond %{REQUEST_URI} !^(.*)/(abc|xyz)(.*)$ [NC]
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ initialize.php [QSA,L]
安全请求应为abc 或xyz。问题是如果请求http:// example.com/abc,它会重定向到http://example.com/initialize.php。非安全页面按预期工作。
【问题讨论】:
标签: performance apache http .htaccess ssl