How to rewrite URL in .htaccess if it does not end with language ID or country ID
In my case I want the redirect link not to end with
home/(en | fr| ar)/(us| ma |ae | sa )
For example:
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)/(.*)$ / [L,R=301,QSA]
But it didn't work
thank you all
You can use the following redirect rules:
(?!(?:en|fr|ar)/(?:us|ma|ae|sa))
is a negative lookahead condition if/home
If it is not followed by the allowedlanguage/country
code, the match will fail.