rewrite all pages /en/XXX to /en

Viewed 110

It's been a while since I've been busting my head to do a htaccess rewrite. I would like to redirect all the pages from example.com/en/XXX to example.com/en. I'm doing either redirection loops or errors 500.

Is it possible to help me to find the right formula?

I tried RewriteRule ^en/(.+)$ /en/ L,QSA also this RewriteRule ^/en\/.*$ http://example.com/en/$1 [R=permanent,L]

Do you also know good links to learn htaccess and rewrite?

thank you in advance for your help

1 Answers

You need to put a condition to stop Looping, could you please try following once, base on your shown samples only.

RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/en/.*/?$ [NC] [L]
RewriteRule ^(en)/.*$ http://example.com/$1 [NC,L]

Merci RaVinder pour ton aide ! <3

Related