Reputation: 23
We have a domain alias which we would like to redirect to the main primary domain which is working all good and well, but how do we redirect the domain alias to a page on the main website.
I have the following code in the .htaccess added (as below) but it is redirecting to the homepage which also breaks the actual page we want to redirect too.
RewriteCond %{HTTP_HOST} ^(www\.)?domainalias\.co.uk$ [NC]
RewriteCond %{THE_REQUEST} !/pirate-golf [NC]
RewriteRule ^(.*)$ /pirate-golf [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.co.uk$ [NC]
RewriteRule ^pirate-golf$ https://www.domainalias.co.uk [L,R=301,NE]
We want the domain alias to redirect to the main domain page like the following example: www.domainalias.co.uk to redirect to www.maindomain.co.uk/pirate-golf.
Any help on this would be great, thanks.
Upvotes: 1
Views: 196
Reputation: 133750
With your shown samples/attempts, please try following. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^www\.domainalias\.co\.uk$ [NC]
RewriteRule ^ http://maindomain.co.uk%{REQUEST_URI} [NE,R=301,L]
Make sure these rules are at the top of your htaccess rules file.
Upvotes: 1