.htaccess 301从文件夹重定向到文件会导致文件名末尾的正斜杠

时间:2013-01-27 09:25:09

标签: apache .htaccess redirect

在我的.htaccess文件中,我有以下代码:

Redirect 301 /About http://www.mysite.com/about.html

我遇到的问题是,当您访问www.mysite.com/About时,它会将您转发到www.mysite.com/about.html/而不是www.mysite.com/about.html,而不会使用正斜杠。< / p>

正斜杠导致我的CSS和其他包含的文件中断。我有什么办法可以将重定向转到www.mysite.com/about.html而不是www.mysite.com/about.html/?

更新以显示完整的.htaccess配置:

#Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>

#Turn on URL Rewrite engine
RewriteEngine On
RewriteBase /

#Allow PHP in .html files
AddHandler application/x-httpd-php .html

#Prevent directory listings
Options All -Indexes

#Specify default home page
DirectoryIndex index.html

#301 Permanent Redirects
Redirect 301 /About http://www.mysite.com/about.html

更新

以下代码似乎有效,但只有在转到/ About /时,所以如果你只是去/关于那么我遇到了同样的问题,正斜杠被添加到网址的末尾。

Redirect 301 /About/ http://www.mysite.com/about.html

0 个答案:

没有答案