-
Apache .htaccess – Subdomain redirect rules
Posted on February 26th, 2009 3 commentsIn the begin of my website i have had a lot of problems to find a good working .htaccess configuration file. I need some redirect rules from specific folders from a subdomain to redirect to specific folder in other subdomain, passing parameters.
I need this type of redirect because my website is multilangue, so i dont want folders on portuguese associated with the english subdomain by example.
This code was really hard to get working, but here it is for you guys, hope it be useful.
– part of the .htacces file of gwebtools.com –
<IfModule mod_rewrite.c>
RewriteEngine On#redirect gwebtools.com to www.gwebtools.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=301,L]#if subdomain pt or whois and folder port-scanner redirect to pt.gwebtools.com/scanner-porta, with parameters
RewriteCond %{HTTP_HOST} ^(pt|whois)\.gwebtools\.com
RewriteRule ^port-scanner/* http://pt.gwebtools.com/scanner-porta$1 [R=301,L]</IfModule>
The above code is running on this site www.gwebtools.com!
3 responses to “Apache .htaccess – Subdomain redirect rules”
-
Can you please help me with htaccess and redirect things. I’m totally new with this.
I have website called domain.com.au with two subdomains:
suba.domain.com.au and subb.domain.com.au
Threeof them are all separate & different websites.
I need to redirect suba.domain.com.au to suba.com.au and subb.domain.com.au to subb.com.au.How do I do it? If I need to change the htaccess, what should I write?
-
I have some problem with this htaccess. It gives internal server error… any help will be appreciated.
-
Hi,
i am having subdomain1.domain.com,subdomain2.domain.com….subdomainN.domain.com i want them to redirect it to domain.com/subdomain what i need to write in the.htacess file .Thanks in advance
Leave a reply
-
