.htaccess redirect url ending with

sAs59

How can I redirect url's ending with catalogue.php, for example

http://www.example.com/catalogue.php

to

http://www.example.com/all

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]
Zudwa

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related