简体   繁体   中英

How to use .htaccess to redirect sub domain to another folder, not URL

I have hosting with no domain pointing to it at present (because I changed the A record to point to another host).

How can I use .htaccess to point my subdomain to the root of the hosting? Also, can the .htaccess file sit in the subdomain's folder because if it goes in the root, I assume it won't be called because the domain points elsewhere.

My folder structure is like this:

  • the root is: /httpdocs
  • the subdomain is: /subdomains/old/httpdocs

I hope I am not mistaken when I read the question. Here you can't use .htaccess to point your subdomain to the root of the hosting.

On your case you can point your subdomain to the root of the hosting by setting your subdomain exactly the same IP address before you changed your A record.

Say old setting of your A record it point to IP 123.123.123.123

A 123.123.123.123

Now say you have change your A record point to another host say IP 456.456.456.456. So all you need is set your sub domain to the same IP of your A record before it was changed.

A 456.456.456.456
subdomain 123.123.123.123

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