Redirecting a subdomain to a folder on the main domain?

Posted by Max Renn, 11-12-2012, 02:46 AM
Hi all I hope someone can help me with this. Do any of you know how I can redirect a subdomain to a folder on the main domain? I need to use a wildcard for the domain. For example: If someone goes to http://m.domain1.com they should get redirected to http://www.domain1.com/somefolder/index.php If someone goes to http://m.domain2.com they should get redirected to http://www.domain2.com/somefolder/index.php I do not know what the domains will be, so I need to use a wildcard or some sort of SERVER_NAME variable in place of domain1 and domain2. Thank you!

Posted by MikeDVB, 11-12-2012, 03:09 AM
It's do-able with mod_rewrite, or you can point the domain to the same location and have your script check and redirect.

Posted by Max Renn, 11-12-2012, 03:49 AM
Thanks for the reply. I have been trying to get it to work with mod_rewrite but I am having no luck. Would you know what I need to put in the .htaccess file? Thanks

Posted by File1eu, 11-12-2012, 03:18 PM
It can be done, although it took us some time to figure out. This is what we have in .htaccess. Replace file1.info with your domain name. Configure Apache to listen on a wildcard address like this: You also need access to your DNS records. It's important that you put this entry at the end, after all the other records. Replace 127.0.0.1 with the IP address of your website and replace file1.info with the domain name of your website. Example: webhostingtalk.file1.info

Posted by Max Renn, 11-13-2012, 10:48 AM
Thank you so much! You are a very helpful person.

Byla tato odpověď nápomocná?

 Tisknout tento článek

Také čtěte

[PHP] - Why forums don't use $_SESSION variables ?

Posted by hadoken, 03-13-2007, 02:46 PMHello, I hope everybody is fine. I take a look on some...

JaguarPC reselling program?

Posted by Snoopy, 09-28-2001, 11:22 PMHi, I am looking for a good reseller program....

Lots of dedicated server problems.

Posted by erix920, 05-07-2007, 08:26 PMOur current problem is that when we try to start sshd...

CNAME or A record in DNS Zone?

Posted by olddocks, 01-14-2008, 08:14 AMi have just created a dns ZONE for my domain, but i dont...

Command for tranferring files through wget

Posted by ramdak5000, 07-16-2007, 10:24 PMI am trying to move over a client from Verio's hosting...