【发布时间】:2017-07-11 02:47:39
【问题描述】:
我在托管平台 http://example.com 上有一个托管域 http://example2.com。
问题是,如果我转到http://example2.com/example2/fr,我不会被重定向到http://example2.com/fr,我已经尝试了解决方案,但仍然有重定向循环。
在 public_html 文件夹中,有一个子文件夹 /example2,其中包含 http://example2.com 的文件
> public_html
- .htaccess
- index.php
> assets
> css
> js
> example2
- .htaccess
- index.html
> fr
- index.html
> en
- index.html
现在,在 public_html 文件夹中,我的 .htaccess 文件中的重定向规则是:
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect the example2 to the subfolder /example2
RewriteCond %{HTTP_HOST} ^(www\.)?example2\.com$ [NC]
RewriteRule !^example2/ /example2%{REQUEST_URI} [L,NC]
</IfModule>
在 /example2 文件夹中,我的 htaccess 文件重定向如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1 [R=301,L]
#RewriteRule ^(.*)$ /$1 [R=301,L]
</IfModule>
【问题讨论】:
-
如果您删除 /subfolder/.htaccess 会发生什么?
标签: apache .htaccess mod-rewrite