Reputation: 93
im using this htaccess code..
RewriteRule ^city/barcelona ?what=2&type=barcelona
RewriteRule ^city/newyork ?what=2&type=newyork
RewriteRule ^city/paris ?what=2&type=paris
RewriteRule ^city/london ?what=2&type=london
RewriteRule ^city/milan ?what=2&type=milan
RewriteRule ^city ?what=3 [L]
But, when i open www.example.com/city/tokyo, it opens www.example.com/city (there is no tokyo option.. it must return 404 page)
How can correct my htaccess code?
(for example.. can i say something like that: if city is newyork, paris or london, do this rewrite rule.. else = 404)
Upvotes: 1
Views: 12
Reputation: 784918
It is happening due to anchors not being used in your rules. Hence your last rule is always matching any URI starting with `/city.
Have it this way:
RewriteRule ^city/barcelona/?$ ?what=2&type=barcelona [L,QSA]
RewriteRule ^city/newyork/?$ ?what=2&type=newyork [L,QSA]
RewriteRule ^city/paris/?$ ?what=2&type=paris [L,QSA]
RewriteRule ^city/london/?$ ?what=2&type=london [L,QSA]
RewriteRule ^city/milan/?$ ?what=2&type=milan [L,QSA]
RewriteRule ^city/?$ ?what=3 [L,QSA]
Upvotes: 1