Home > Software design >  .htaccess Redirect traffic from new domain to another folder
.htaccess Redirect traffic from new domain to another folder

Time:10-23

I have two domains pointing to the same server.

Domain A is my historical domain.

Domain B is a new domain and is an alias for Domain A. I have no hands on DNS configurations for that domain.

I want Domain B to point to a folder of my server (or a sub-domain of Domain A) using .htaccess

Thanks

CodePudding user response:

This probably is what you are looking for:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$
RewriteCond %{REQUEST_URI} !^/folder/domainB/
RewriteRule ^ /folder/domainB%{REQUEST_URI} [L]

An alternative would be that:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$
RewriteRule ^/?folder/domainB(/.*)$ https://%{HTTP_HOST}$1 [R=301,END]
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$
RewriteRule ^ /folder/domainB%{REQUEST_URI} [END]
  • Related