Search code examples
.htaccesshttp-redirecturl-rewritinghttp-status-code-301

.htacces redirect specific folder/subfolder


I am trying to make this work, please help me in it, if you can:

1. I have a specific folder on an old domain, with a lot of subfolder. Looking like this:

OLD-DOMAIN / FOLDER / something1 etc.

2. I would like to redirect it to a new domain's specific ABCD folder.

NEW-DOMAIN / ABCD / FOLDER / something1 etc.

I have been using this code:

RewriteCond %{REQUEST_URI} ^/(FOLDER)$
RewriteRule ^ http://www.newdomain.com/**ABCD**/%1 [L,R=301,NC]

The code is working just fine for the first FOLDER, but not for the deeper subfolders. The /something1 doesnt redirecting through the chain.

How can I make this special redirect to every subfolders? Thanks in advance!


Solution

  • Just change your rule to this:

    RewriteRule ^FOLDER(/.*)?$ http://www.newdomain.com/ABCD/$0 [L,R=301,NC,NE]
    

    Clear your browser cache before testing this change.