Reputation: 649
I would like the last parameter/directory from the following urls:
http://example.com/movies/randomMovie
http://example.com/books/randomBook
to be passed like following:
http://example.com/movies.php?=randomMovie
http://example.com/books.php?=randomBook
I have tried the following:
RewriteEngine on
RewriteRule ^([^/d]+)/?$ movies.php?=$1 [QSA]
RewriteRule ^([^/d]+)/?$ books.php?=$1 [QSA]
But that overwrites the rule for (movies.php).
How do I achieve this in .htaccess?
Upvotes: 2
Views: 450
Reputation: 784938
Your rule is not matching /movies/
and /books/
, you can use this rule:
RewriteEngine on
RewriteRule ^movies/([^/]+)/?$ movies.php?=$1 [L,QSA,NC]
RewriteRule ^books/([^/]+)/?$ books.php?=$1 [L,QSA,NC]
Upvotes: 2
Reputation: 2785
Try this
RewriteEngine on
RewriteRule ^movies/([a-zA-Z]+)/?$ movies.php?=$1 [L, QSA]
RewriteRule ^books/([a-zA-Z]+)/?$ books.php?=$1 [L, QSA]
Upvotes: 1