Jump to content

[SOLVED] .htaccess redirect help


Cory94bailly

Recommended Posts

Hey guys..

 

I want to redirect http://mysite.com TO http://forum.mysite.com

 

But since the folder 'forum' and 'blog' are in my www root folder, I don't want them to be affected..

We have an mod_rewrite board here that would have been a more suitable place to post.

 

Anyway, something like this within your doc root should do it.

 

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

We have an mod_rewrite board here that would have been a more suitable place to post.

 

Anyway, something like this within your doc root should do it.

 

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

 

Sorry about that, didn't see it :)

 

Now would that redirect something like 'http://mysite.com/sjidsdijg' to 'http://forum.mysite.com/sjidsdijg'?

I tried learning .htaccess for the past week now and it's just confusing to me.. I'm sorry for not learning..

 

You should be able to quickly figure out how to do this your self x.x.

 

 

Anyway:

 

 

RewriteRule ^$ http://blog.blah.com/ [R=301,L]

RewriteRule (.*) http://forum.blah.com/$1 [QSA,R=301]

 

That brings me to http://forum.mysite.com/_forum/_forum/_forum/_forum/_forum/_forum/_forum/_forum/_forum/_forum/_forum/

 

And same for blog..

 

It seems to be redirecting even when already in the subdomain..

It would sound then like it's going into an infinite loop because your forum subdomain is being affected by the same htaccess file.

 

 

(The blog one is probably also loop infinitely but it's probably not as apparent since it will still work correctly.)

 

 

So basically you can either stop the RewriteRule from affecting the forum/blog folders by over riding it, or you can put a condition in there.

 

 

(The condition is borrowed from thorpe)

 

RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com [NC]

RewriteRule ^$ http://blog.blah.com/ [R=301,L]

RewriteRule (.*) http://forum.blah.com/$1 [QSA,R=301]

It would sound then like it's going into an infinite loop because your forum subdomain is being affected by the same htaccess file.

 

 

(The blog one is probably also loop infinitely but it's probably not as apparent since it will still work correctly.)

 

 

So basically you can either stop the RewriteRule from affecting the forum/blog folders by over riding it, or you can put a condition in there.

 

 

(The condition is borrowed from thorpe)

 

RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com [NC]

RewriteRule ^$ http://blog.blah.com/ [R=301,L]

RewriteRule (.*) http://forum.blah.com/$1 [QSA,R=301]

 

I'm sorry but it still does the same thing..

Oh, you might actually need the Cond twice:

 

 

RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com [NC]

RewriteRule ^$ http://blog.blah.com/ [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com [NC]

RewriteRule (.*) http://forum.blah.com/$1 [QSA,R=301]

Oh, you might actually need the Cond twice:

 

 

RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com [NC]

RewriteRule ^$ http://blog.blah.com/ [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?blah\.com [NC]

RewriteRule (.*) http://forum.blah.com/$1 [QSA,R=301]

 

Thank you so much, that works perfectly ;)

 

I'm sorry for any trouble..

 

/solved

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.