简体   繁体   中英

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?

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]

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM