I have a few domains all on one hosting.
Based on the domain name they type, can i forward them to root.com/domain/ via htaccess?
I have a few domains all on one hosting.
Based on the domain name they type, can i forward them to root.com/domain/ via htaccess?
isn't that a host header thing ? ( in IIS anyways )
I seem to remeber apache supports it to, with virtual roots ?
my Virtualisation Blog http://jfvi.co.uk Virtualisation Podcast http://vsoup.net
this is separate from all my other q's this is my personal webspace, with which i dont have much control, only HTaccessOriginally Posted by Moby-Dick
You have scripting support on the host?
In ASP you can do a server-side redirect, for example.
~ I have CDO. It's like OCD except the letters are in alphabetical order, as they should be. ~
PC: Win10 x64 | Asus Maximus VIII | Core i7-6700K | 16GB DDR3 | 2x250GB SSD | 500GB SSD | 2TB SATA-300 | GeForce GTX1080
Camera: Canon 60D | Sigma 10-20/4.0-5.6 | Canon 100/2.8 | Tamron 18-270/3.5-6.3
If you have server rewriting rules activated on your hosting (e.g. mod-rewrite in Apache) you can do this via .htaccess.
An example from my website for supporting multiple sub-domains:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} example.co.uk$
RewriteCond %{REQUEST_URI} !default
RewriteRule ^(.*)$ default/$1
RewriteCond %{HTTP_HOST} www.example.co.uk$
RewriteCond %{REQUEST_URI} !default
RewriteRule ^(.*)$ default/$1
RewriteCond %{HTTP_HOST} richard.example.co.uk$
RewriteCond %{REQUEST_URI} !richard
RewriteRule ^(.*)$ richard/$1
RewriteCond %{HTTP_HOST} david.example.co.uk$
RewriteCond %{REQUEST_URI} !david
RewriteRule ^(.*)$ david/$1
This directs all requests for the main website to the "default" directory, and the sub-domains "david" and "richard" to respective directories.
The rules are applied recursively, so each of these rules is basically saying: "if the domain they've typed is richard.example.co.uk, and the filename they've asked for doesn't start with richard, then add "richard/" to the start of the filename. You need the check that you haven't already added the directory prefix, otherwise it will create an infinite loop! I found this the hard way :-)
Do a search on google for URL rewriting via .htaccess, or give us some more detail about what exactly you want to achieve and I'll try to help :-)
There are currently 1 users browsing this thread. (0 members and 1 guests)