DTN
10-24-2005, 01:59 AM
Does anyone know how to redirect the main domain to a subdomain name by using .htaccess?
Thanks a lot,
DTN
Thanks a lot,
DTN
![]() | View Full Version : redirect domain to sub domain DTN 10-24-2005, 01:59 AM Does anyone know how to redirect the main domain to a subdomain name by using .htaccess? Thanks a lot, DTN glued2 10-24-2005, 02:15 AM You should just be able to use the redirect directive: Redirect / http://sub.domain.com http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirectpermanent DTN 10-24-2005, 02:46 AM here's how i did but when i type in www it won't redirect to the subdomain that i wanted sample: RewriteEngine On Options +FollowSymlinks RewriteCond %{HTTP_HOST} =domain.com [NC] RewriteRule ^ http://sub.domain.com [R,L] extras 10-24-2005, 04:56 PM How about this? RewriteEngine On Options +FollowSymlinks RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] RewriteRule ^ http://sub.domain.com [R,L] DTN 10-24-2005, 09:45 PM Originally posted by extras How about this? RewriteEngine On Options +FollowSymlinks RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] RewriteRule ^ http://sub.domain.com [R,L] Thanks extras, it works so well ;) dchristjohn 06-15-2006, 12:01 AM I've been trying to get this to work myself and used about 20 tips from others that were completely wrong or didn't work. This one worked and I wanted to post a thank you. Peace, Dan extras 06-21-2006, 10:48 AM Somehow, RewriteRules remained as the dark corner of web hosting. I spent hours and hours not because I needed but to help other users of forum like this one and others. I think i spent more time than anyone else in testing many different RewriteRule sets for all sorts of purposes. And I can say that it's not always easy to test things, especially if the server has non-standard setup, or if it's for a (live) host and we can't use RewriteLog. Also, modules like Frontpage and even mod_php can mess up with how things are treated. In short, now I understand why people don't want to know much about it. :) celio 06-23-2006, 05:28 AM Go and edit the httpd.conf file in there you will h have something like <VirtualHost YourIP> ServerName Your domain n ame DocumentRoot Your domain n ame bla bla <VirtualHost YourIP> Copy that and create something like this <VirtualHost YourIP> ServerName Your SUBDOMAIN NAME DocumentRoot Your SUBDOMAIN NAME bla bla - keeep the local paths change the URL ones <VirtualHost YourIP> See if that works for you.. it does for meee :D Blue Dot Labs 06-23-2006, 09:56 AM I have the following .htaccess file to redirect a subdomain RewriteEngine On RewriteCond %{HTTP_HOST} distortedsilence.org$ [NC] RewriteCond %{REQUEST_URI} !^/distortedsilence/.*$ RewriteRule ^(.*)$ /distortedsilence/$1 This works fine, but I can't run php files. http://distortedsilence.org/test.php gives me the following error The requested URL /distortedsilence/cgi-bin/php/distortedsilence/test.php was not found on this server. PHP is running out of the cgi-bin on my account, any idea of what I can add to my .htaccess file in order to let it run php files from my redirected domain. If "/distortedsilence" is removed from the beginning of that line the path would be correct. How would I do that? serversolutions 07-21-2006, 05:29 PM Ive tried the examples you put on here but they dont seem to work for me how come do you have to own the domain for it to work? glued2 07-22-2006, 08:22 AM You have to add the DNS records for the domain (to create the subdomain) - this info is about the webserver config. Ask your provider to add DNS records for what ever sub domains you are after. |