I have the following code which is working perfectly for rewriting and redirecting
domain.com/pais.php?nombre=Andorra to domain.com/Andorra/
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\s/+pais\.php [NC]
RewriteCond %{QUERY_STRING} (^|&|\?)nombre=(.*)(&|$) [NC]
RewriteRule . /%2/? [R=301,L,NC]
RewriteRule ^([^/]*)/$ /pais.php?nombre=$1 [L]
What I need to do know is do the same thing with
domain.com/ciudad.php?nombre=Andorra&ciudad=Andorra+La+Vella
it should go to
domain.com/Andorra/Andorra+La+Vella/
I'm not sure how to use 2 variables in rewrite condition.
Can anyone help me? Thanks
You'd need another set of rules, but the longer one just needs to come first:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\s/+pais\.php [NC]
RewriteCond %{QUERY_STRING} (^|&|\?)nombre=(.*)&ciudad=(.*)(&|$) [NC]
RewriteRule . /%2/%3/? [R=301,L,NC]
RewriteRule ^([^/]*)/([^/]+)/$ /pais.php?nombre=$1&ciudad=$2 [L]
RewriteCond %{THE_REQUEST} ^GET\s/+pais\.php [NC]
RewriteCond %{QUERY_STRING} (^|&|\?)nombre=(.*)(&|$) [NC]
RewriteRule . /%2/? [R=301,L,NC]
RewriteRule ^([^/]*)/$ /pais.php?nombre=$1 [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.