【发布时间】:2015-11-18 14:37:59
【问题描述】:
我在我的 .htaccess 文件中启用了 RewriteEngine。我有条件从任何请求中删除“www”。这工作得很好。但是,我也在使用 RedirectMatch 进行 301 重定向。除了将来自原始传入 url 的请求 URI 附加到我 301 重定向到的 url 的末尾之外,这也有效。
输入网址:
http://www.example.com/newplate
输出网址:
http://example.com/contact/motorv.php?/newplate
现有的 .htaccess 文件
AddOutputFilter INCLUDES .shtml .html .htm .php
RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,L]
#straight 301 redirects
RedirectMatch 301 ^/newplate(.*) /contact/motorv.php
#if request is not an existing file or directory then redirect to
#codeigniter boot.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ boot.php?/$1 [L,QSA]
应该如何解决这个问题?有没有我忽略或写错的地方?
【问题讨论】: