反正有没有摆脱文件夹,但转到子文件夹

时间:2014-02-28 14:18:01

标签: apache .htaccess

我想让我的网站来自

www.example.com/folder/subfolder

www.example.com/subfolder

我只能将我重定向到

www.exmaple.com/folder/

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(.+)\www.example\.com$
RewriteRule ^/(.*)$ /folder/%1/$1 [L]

----更新----

这些是当前的重写规则。

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^folder/(.*)$ /$1 [L,NC]

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

1 个答案:

答案 0 :(得分:0)

您可以使用:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^((?!folder/).*)$ /folder/$1 [L,NC]