Jump to content

[SOLVED] .htaccess redirect help


Cory94bailly

Recommended Posts

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'?

Yep.

 

Thanks alot!

 

Sorry for one last thing..

 

I want it so if they go straight to http://mysite.com, redirect them to http://blog.mysite.com.. If they go to ANYTHING other than just http://mysite.com, redirect them to http://forum.mysite.com..

 

 

 

Examples:

http://mysite.com - http://blog.mysite.com

http://mysite.com/4946 - http://forum.mysite.com/4946

http://blog.mysite.com/index.php - NO CHANGE

 

I hope that's possible ;)

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]

 

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.