0

My old url

www.example.com/cn/news
www.example.com/cn/event

I want to if user enter /cn url Laravel will redirect into this url

www.example.com/en/news
www.example.com/en/event

here is my laravel .htaccess in root folder

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

I try this one but it doest work

 RewriteCond %{THE_REQUEST} /cn [NC]
   RewriteRule ^ /%1/en/%2/? [L,R=301]

UPDATE

now .htaccess look like this but still didnt work RewriteEngine On RewriteRule ^(.)$ public/$1 [L] RewriteRule ^cn/(.)$ en/$1 [L,R=301]

1 Answer 1

0
RewriteRule ^cn/?(.*)$ en/$1 [L,R=301]

This rule alone should work.

Match a cn prefix with an optional / and capture all characters after the /.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.