Arthur
Arthur

Reputation: 2110

Redirect root of website only with apache and .htaccess

I am looking to redirect only the root of my domain to another domain with apache + .htaccess - However I would like to maintain current directories.

Example:

http://www.domain-one.com/ would redirect to http://www.domain-two.com/

However anything after the / would be ignored, examples:

http://www.domain-one.com/contact

http://www.domain-one.com/?param=1

Upvotes: 0

Views: 47

Answers (1)

anubhava
anubhava

Reputation: 784928

You can use this rule in the site root .htaccess of domain-one:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain-one\.com$ [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?$ http://www.domain-two.com/ [L,R=301]

Upvotes: 1

Related Questions