skip to Main Content

I was using translatepress on my WordPress site so my site URLs were like example.com/en-ae/hair-transplant but now I have removed translatepress so now my URLs are like example.com/hair-transplant but I have submitted URLs for SEO with the en-ae slug. I want that if en-ae is present in any URL then it gets removed automatically and gets redirected to page without en-ae.

For example example.com/en-ae/hair-transplant redirects to example.com/hair-transplant.

2

Answers


  1. You need the rewrite module of Apache: mod_rewrite.

    Then in your htaccess this:

    RewriteEngine on 
    RewriteRule ^en-ae/(.*)$ $1
    
    Login or Signup to reply.
  2. To remove the /en-ae prefix from all requested URLs (to help preserve SEO), you would need to add the following near the top of the root .htaccess file, before the WordPress code block (ie. before the # BEGIN WordPress comment marker):

    # Remove "/en-ae/" prefix from all requests
    RewriteRule ^en-ae/(.*) /$1 [R=301,L]
    

    You do not need to repeat the RewriteEngine directive, which already occurs later in the file (in the WordPress code block).

    The R=301 flag triggers an external "permanent" redirect – without which the URL-prefix is not actually removed. However, you should first test with a 302 (temporary) redirect to avoid potential caching issues.

    The slash prefix on the substitution string is necessary to avoid a malformed redirect, if the RewriteBase directive is omitted from the WordPress code block.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search