.htaccess重定向到文件会混淆文件夹名称

时间:2016-09-02 02:27:09

标签: .htaccess redirect

我不知道如何使用.htaccess,但到目前为止我已经进行了简单的重定向。

Redirect /global-awards http://religiousfreedomandbusiness.org/global-awards.html

问题是我有一个名为/ global-awards /的文件夹 因此,当我尝试访问global-awards / finalist.html时,浏览器会将文件夹的名称更改为/ global-awards .html / finalist.html

编辑: 多视图代码:

Options -MultiViews
DirectoryIndex index.php

Redirect /global-awards http://religiousfreedomandbusiness.org/global-awards.html

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

2 个答案:

答案 0 :(得分:1)

请勿将mod_aliasRedirect指令与mod_rewrite规则混合使用。喜欢这样:

Options -MultiViews
DirectoryIndex index.php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L,NC]

RewriteRule ^global-awards/?$ /global-awards.html [L,NC,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

确保在测试此更改之前清除浏览器缓存。

答案 1 :(得分:-1)

尝试

--debug

在你的htaccess顶部,如果不能正常工作,请告诉我。

相关问题