Reputation: 2489
I have enabled RewriteEngine within my .htaccess file. I have a condition to remove the "www" from any request. This works just fine. However I am also using RedirectMatch to do a 301 redirect. 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.
Input URL:
http://www.example.com/newplate
Output URL:
http://example.com/contact/motorv.php?/newplate
Existing .htaccess file
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?
Upvotes: 0
Views: 499
Reputation: 18671
You can use:
#straight 301 redirects
RewriteRule ^newplate(.*) /contact/motorv.php [NC,L,R=301]
Upvotes: 1