Charles
Charles

Reputation: 77

Redirect alias to main domain using htaccess

I'm attempting to redirect my client's domain alias (http://5sensescharity.co.uk) to their main domain http://5senses.co.uk.

I seem to have got this working using a response from another user's question, but can't get it working with every other possible url after the root. E.g 5sensescharity.co.uk/about/

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?5sensescharity\.co.uk [NC]
RewriteRule ^(.*)$ http://5senses.co.uk/$1 [R,L]

Upvotes: 3

Views: 3474

Answers (2)

jotik
jotik

Reputation: 17920

I'd rather try to use the Apache RedirectPermanent or RedirectTemp directives from mod_alias, because they're usually faster for Apache to process, e.g.:

RedirectPermanent / http://5senses.co.uk/

or

RedirectTemp / http://5senses.co.uk/

Upvotes: 2

anubhava
anubhava

Reputation: 786031

Try this rule:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?5sensescharity\.co.uk$ [NC]
RewriteRule ^ http://5senses.co.uk%{REQUEST_URI} [R,L,NE]

Upvotes: 1

Related Questions