How to rewrite URL in .htaccess when URL does not end with language ID or country ID
P粉005105443
P粉005105443 2024-01-16 20:15:01
0
1
430

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

P粉005105443
P粉005105443

reply all(1)
P粉211273535

You can use the following redirect rules:

RewriteRule ^home/(?!(?:en|fr|ar)/(?:us|ma|ae|sa))([^/]+/[^/]+) / [L,R=301,NC,NE]

(?!(?:en|fr|ar)/(?:us|ma|ae|sa)) is a negative lookahead condition if /home If it is not followed by the allowed language/country code, the match will fail.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!