How to Rewrite urls if not ends with language id or country id in .htaccess
in my case i want redirect links not ends with
home/(en | fr| ar)/(us| ma |ae | sa )
for exemple:
https://exemple.com/home/en/sa/...
https://exemple.com/home/es/sa/...
https://exemple.com/home/ar/...
I tried this:
RewriteRule ^home/!(en|ae|sa)/!(sa|ma|ae|sa)/(.*)$ /$1 [L,R=301,QSA]
but it didn't work
Thank you all
You may use this redirect rule:
RewriteRule ^home/(?!(?:en|fr|ar)/(?:us|ma|ae|sa))([^/]+/[^/]+) /$1 [L,R=301,NC,NE]
(??(:?en|fr|ar)/(::us|ma|ae|sa))
is a negative lookahead condition that will fail the URL match if /home
is not followed by allowed language/country
codes.
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.