How to rewrite a htaccess rule

I made a mistake on my site setup and now I need a 301 rewriterule to change all URLs from

https://www.example.com/es

to

https://www.example.com/mx

and everything that comes after /es or /mx

Thank you

My .htaccess is a bit rusty, but this should do the trick

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^es(.*)$ /mx$1 [L,R=301]

To test, use R=302 instead of 301 so your browser won’t cache the result, making it easier to make minor adjustments and debug if need be.

@rpkamp

Thank you

I’ll give it a try

@rpkamp

Works perfect!

Nice! Now you got it working make sure you use 301 instead of 302 again.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.