|
I would like my website to check the hostname/website name requested and redirect it to the correct folder. I don't know how to do this? A redirection script maybe? Help, please.
How do you program a website's index file to check the host name requested and redirect accordingly?
Alongside the virtual host facility described on the hosting page I want to make sure that people who try to access the subdirectories directly are redirected to the correct URL. This ensures that links given within the sites as relative to the site root work correctly. Ie. I want the link <a href="http://www.imwebhost.com/"/">" in hannah.edgingtonfamily.org always to point to /hannah/, not to the real site root. This would be a problem if someone accessed the site as http://www.edgingtonfamily.org/hannah/. Therefore I arrange for that URL to redirect the UA to the correct place by putting the following in the real root .htaccess file.
/.htaccess
Redirect permanent /hannah/ http://hannah.edgingtonfamily.org/
Redirect permanent /ben/ http://ben.edgingtonfamily.org/
Redirection can also be useful if you move things around within your site to point people transparently to the new location. But don't do this too much; it easily gets very complicated!
|