![]() |
htaccess subdomain & non-www to www redirects.
They seem to interfere with eachother, the non-www to www redirect overwrites the subdomain to subdir redirect so subdomains just go to www.mydomain.com without subdir.
Let me explain the situation, i have subdomains i want to their respective subdir. So title.mydomain.com to www.mydomain.com/title/ titletwo.mydomain.com to www.mydomain.com/titletwo/ etc. But right now i also have the non-www to www redirect code: RewriteEngine on RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC] RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] But when i add this subdomain to subdir code to the htaccess (which redirects all subdomains to subdirs except when it's www): RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com [NC] RewriteRule (.*) http://www.mydomain.com/%1/$1 [R=301,L] .... it just redirects the subdomains to the home page www.mydomain.com. How do i do this? |
Try this maybe:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d [NC] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com [NC] RewriteRule (.*) http://www.mydomain.com/%1/$1 [R=301,L] |
no that doesnt make a difference
|
EDIT:
Nevermind |
not 100% sure but you might need to have wildcard domains enabled on the host?
I know wordpress MU (for multiple blogs on subdomains) won't work unless the host has wildcard domains enabled anyway, just a guess |
Tested this on mine, so far it worked. Maybe you can mix it up from here.
RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC] RewriteCond %1 !^(www)$ [NC] RewriteRule ^$ /%1/$1 [L] RewriteCond %{HTTP_HOST} ^domain\.com$ RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] |
Thanks for the effort, but that doesnt work at all doesnt even redirect to the main domain
Let me show you how the htaccess looks: Code:
RewriteEngine on edited a bit |
hm i have an idea.. will test it later and report if it worked. Now im having a break
|
i tested it and it works, so dont say it doesnt :p
Code:
Options +FollowSymLinks |
well thanks but it doesnt work for me..... gonna email my host.
|
bump for nico-t if he didnt get it
|
no luck for me fris i see we posted at same time anyway i emailed my host usually they are pretty fast with solving any issues.... ill post here what it is once i get a reply...
|
All times are GMT -7. The time now is 03:07 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123