Subdomain and Root Rewrite Problem

Using a single web hosting account to host multiple sites

Subdomain and Root Rewrite Problem

Postby Magnizmo » Sun Oct 11, 2009 5:51 pm

Hi all ,

First time poster here and Im a bit of a newbie when it comes to mod_rewrite

I am having a problem with one of my sites and I have my .htaccess set up like this

RewriteCond %{HTTP_HOST} !^www\.site\.com$ [NC]RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]


now when i create a subdomain instead of the url structure being subdomain.site.com it redirects to site.com/subdomain ?

I know that the rule is saying to redirect if the hostname is not www.site.com which subdomains will trigger the rules and get redirected.

its just i dont have a clue on how to fix this..

at the moment i have set up a .htacces file with mod_rewrite off on the subdomain. But for seo reasons i need it turned on..

Hope i am making sense and I appreciate your help :)

Regards
Waza
Magnizmo
 
Posts: 5
Joined: Sun Oct 11, 2009 5:44 pm
Location: Australia

Postby richardk » Mon Oct 12, 2009 2:15 am

What's supposed to happen??
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Magnizmo » Mon Oct 12, 2009 4:01 am

richardk wrote:What's supposed to happen??



When i create a new sub domain it redirects to site.com/subdomain instead of being subdomain.site.com

because of the way i have my .htaccess set up it is causing this redirect. I just dont know how to fix it.

also when i have mod rewrite turned on in my subdomain i get 404 pages all over the site except the home page..
Magnizmo
 
Posts: 5
Joined: Sun Oct 11, 2009 5:44 pm
Location: Australia

Postby richardk » Mon Oct 12, 2009 2:36 pm

What's the mod_rewrite supposed to do?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule .* http://www.%1%{REQUEST_URI} [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Magnizmo » Mon Oct 12, 2009 3:26 pm

richardk wrote:What's the mod_rewrite supposed to do?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule .* http://www.%1%{REQUEST_URI} [R=301,L]


Sorry, the mod rewrite is just supposed to redirect example.com to the www.example.com

but as stated it is effecting my subdomains as well.
Magnizmo
 
Posts: 5
Joined: Sun Oct 11, 2009 5:44 pm
Location: Australia

Postby richardk » Tue Oct 13, 2009 2:14 am

The mod_rewrite from my last post should work then. You may need to clear your browser's cache.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Magnizmo » Tue Oct 13, 2009 3:44 am

its really wierd, I have cleared my cache both computer and internet.

no luck still?

Thanks for your help by the way..
Magnizmo
 
Posts: 5
Joined: Sun Oct 11, 2009 5:44 pm
Location: Australia

Postby richardk » Tue Oct 13, 2009 2:35 pm

What happens if you remove it?
Have you removed the ^ from the RewriteCond?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Magnizmo » Fri Oct 16, 2009 8:13 pm

I fixed it.

All I did was add this to each subdomain
RewriteEngine On


Thanks heaps for your help anyway
Magnizmo
 
Posts: 5
Joined: Sun Oct 11, 2009 5:44 pm
Location: Australia


Return to Domain Handling

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron