【发布时间】:2014-07-06 21:55:51
【问题描述】:
我有一个特殊的问题。我需要重写所有发往 http => https 的请求,此外,如果 URL 缺少 www,我想修复它,因此我也有一个重写规则。
现在,有一个例外,不应该重写。如果请求是针对 http://www.mydomain.com/api2/.../..
api2下的所有东西都不要改成https...
这是我当前的 .htaccess :
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
# Start A2 Switcher Block
# Do not remove or modify this block! Added by PHP Switcher from cPanel to use an alterna$
<IfModule mod_suphp.c>
AddHandler application/x-httpd-php-5.4.13 .php
</IfModule>
# End A2 Switcher Block
谁能帮忙?
【问题讨论】:
标签: apache .htaccess mod-rewrite ssl url-rewriting