1

I want to replace this URL:

mydomain.com/posts/1659-artigos/etc-to

By this one:

mydomain.com/etc-to

Using .htaccess I'm trying the following:

RewriteEngine on
RewriteRule ^posts/1659-artigos/(.*)$ $1

But it isn't working. No redirect happens.

Can anyone help?

Thanks!

3
  • 1
    RewriteRule ^posts/1659-artigos/(.*)$ /$1 [L,R=301] should work Commented Aug 5, 2021 at 17:36
  • 1
    Yep, that works, thanks a lot! Write it in the answer! Commented Aug 5, 2021 at 17:40
  • 1
    @anubhava maybe you could also look into this one: stackoverflow.com/questions/68672253/… Commented Aug 5, 2021 at 19:06

1 Answer 1

0

Converting my comment to answer so that solution is easy to find for future visitors.

You can use this code to get redirect working:

RewriteEngine on

RewriteRule ^posts/1659-artigos/(.*)$ /$1 [L,R=301,NC]

You need to use / before $1 for external redirect and make sure to use R flag for full redirect.

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.