【发布时间】:2017-10-05 22:34:44
【问题描述】:
我使用下面的.htaccess 将我的网站从http 重定向到https://www。
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
我有一个子文件夹staging,每当我访问该文件夹时,它都应该重定向到https://www.example.com/staging。
我尝试在我的根 htaccess 中添加以下代码
RewriteCond %{HTTPS} off
RewriteRule ^(staging/.*)$ https://www.%{HTTP_HOST}/$1
还有
RewriteCond %{HTTPS} !=on
RewriteRule ^(staging/.*)$ https://www.example.com/$1
但每次我的网站重定向到https://www.example.com/,如果我尝试不使用https://www,例如
http://example.com/staging
到
https://www.example.com/
我的子文件夹的Htaccess是
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
服务器是engintron
【问题讨论】:
标签: apache .htaccess redirect mod-rewrite cakephp