Hi,
i tried redirecting some folders to the subdomains with the same names as the folders. I tried this way but it didn't work:
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(test1|test2)(.*?)$ http://$1.domain.com$2 [R=301,L]
I guess the problem is that the alternation of folders doesn't return a result that i can get into $1, right?
I'm not a PCRE expert so andy help would be appreciated.
From stackoverflow
-
Try with this:
RewriteCond %{REQUEST_URI} ^/yoursub RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://yoursub.domain.com/$1 [L]
The 2 lines in the middle will prevent redirecting if that folder or file exists. To remove file and folder exception, comment out that 2 lines, and stay with this only:
RewriteCond %{REQUEST_URI} ^/yoursub RewriteRule ^(.*)$ http://yoursub.domain.com/$1 [L]
: Probably my question wasn't clear enough: I want to redirect different folders to different subdomains. The subdomains have the same name as the folders and i'd like to have only one rewrite for all of them. Example: /test -> test.domain.com Example2: /dog -> dog.domain.comCuSS : why don't you configure out the apache insted of rewrite? http://www.howtoforge.com/forums/showthread.php?t=23
0 comments:
Post a Comment