简体   繁体   English

htaccess RewriteCond和RedirectMatch

[英]htaccess RewriteCond and RedirectMatch

I have enabled RewriteEngine within my .htaccess file. 我在.htaccess文件中启用了RewriteEngine。 I have a condition to remove the "www" from any request. 我有条件从任何请求中删除“ www”。 This works just fine. 这样很好。 However I am also using RedirectMatch to do a 301 redirect. 但是我也使用RedirectMatch进行301重定向。 This works as well except that the request URI from the original incoming url is appended to the end of the url which I am 301 redirecting to. 除原始传入URL的请求URI附加到我将301重定向到的URL的末尾之外,此方法同样有效。

Input URL: 输入网址:

http://www.example.com/newplate

Output URL: 输出网址:

http://example.com/contact/motorv.php?/newplate

Existing .htaccess file 现有的.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]

How should this issue be resolved? 该问题应如何解决? Is there something I have overlooked or written incorrectly? 是否有我忽略或写错的东西?

You can use: 您可以使用:

#straight 301 redirects
RewriteRule ^newplate(.*) /contact/motorv.php [NC,L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM