Reputation: 572
How can I redirect url's ending with catalogue.php, for example
to
Not affecting url's like http://www.example.com/catalogue.php?title=titleName&page=2
Tried the following code:
RewriteCond %{REQUEST_URI} /catalogue.php
RewriteRule ^(.*)$ www.example.com/all/$1 [R=301,L]
Upvotes: 0
Views: 2597
Reputation: 1400
Try this:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^catalogue\.php$ /all [R=301,L]
You will be redirected only if requesting /catalogue.php
, wthout any query string parameters.
If you need to specify them, you can change the first line to something similar to:
RewriteCond %{QUERY_STRING} !title|titleName|page
Here redirect will be done only if none of title
, titleName
, page
parameters specified.
Added
If catalogue.php
may be in subfolder, use:
RewriteRule (^|/)catalogue\.php$ /all [R=301,L]
You can read more about regular expressions in order to understand how it works.
Upvotes: 2