user1592565
user1592565

Reputation: 1

301 Dynamic Pages Redirect

Hi I tried various methods with modewriter in htaccess shown in other threads. I want to redirect my url from www.example.com/categories.php?category=1 to www.example.com/categories/science.

I would really appreciate an example too where I'm wrong. Thank You.

Upvotes: 0

Views: 183

Answers (1)

C.A. Vuyk
C.A. Vuyk

Reputation: 1085

Assuming that it is just this one URL you want to redirect it would be like:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^category=1$ [NC]
RewriteRule ^categories.php$ www.example.com/categories/science/? [L,R=301]

This is in case you are using a .htaccess file, otherwise add a prepending slash:

RewriteRule ^/categories.php$ www.example.com/categories/science/? [L,R=301]

The querystring wil be discarded. Only put [R] if you want to show it to the user in the addressbar of the browser. Consider which status you want to serve, Google likes 301 if it's permanent.

Next you have to catch the incoming request with an index.php in the directory www.example.com/categories/science

good luck!

Upvotes: 1

Related Questions