Baklap4
Baklap4

Reputation: 4202

Redirect domain to subdomain with .htaccess

I'm new to hosting a website. At my host i can create a lot of subdomains. At the moment my main page is under construction so i would like to make it go to my subdomain which is finished.

Now i've heard some things about redirecting a domain to a subdomain with the .htaccess file. I've located my .htaccess file at:

/cgi-bin/.htaccess

So i thought it's just adding this line:

Redirect 301 / http://Subdomain.domain.nl/

and then it'll redirect too bad it doesn't somehow. How to fix this?

Upvotes: 1

Views: 583

Answers (2)

Rocketrod
Rocketrod

Reputation: 21

Hi mate I have found this way very easy. Go to the main domain if that's not the one you are using.

<HTML> 
<HEAD>
<META HTTP-EQUIV=Refresh CONTENT="0; url=http://www.subdomain.domain.tld">
</HEAD>
<BODY>
</BODY>
</HTML>

Very easy and with no issues that I have found and better than person going to a UC website.

Hope it helps

Upvotes: 0

anubhava
anubhava

Reputation: 784908

Enable mod_rewrite and .htaccess through httpd.conf (if not already enabled) and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.nl$ [NC]
RewriteRule ^ http://Subdomain.domain.nl/ [L,R]

Upvotes: 1

Related Questions