Answer the question
In order to leave comments, you need to log in
How to register with modrewrite rule?
Faced the problem of implementing the condition for modrewrite.
Task: If the first element of the URL is the name of a city from the list of cities, redirect a request like:
/city_name/category/subcategory/...etc
/category/subcategory/...etc/?city=city_name
RewriteCond %{REQUEST_URI} ^/(bucuresti|verona|sofia)/
RewriteRule ^([a-z0-9-]+)/(.+)$ /$2?region=$1 [R,L]
RewriteCond %{REQUEST_URI} !^/(help|contacts|about)/
RewriteRule ^([a-z0-9-]+)/(.+)$ /$2?region=$1 [R,L]
Answer the question
In order to leave comments, you need to log in
I figured it out... More precisely, they suggested it :)
After the redirect, the new address starts with /cat/ and again matches the condition !^/(help|contacts|about)/
You can optionally check %{QUERY_STRING} for region.
RewriteCond %{QUERY_STRING} !region=
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question