-
Apache .htaccess - Subdomain redirect rules
Posted on February 26th, 2009 1 commentIn 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!

