.htaccess tutorial

htaccess Elite


Redirect ANY request to root of diff domain

Ask your mod_rewrite and Redirection questions here, and get answers!

Redirect ANY request to root of diff domain

New postby crashnet » 27 Jan 2009 22:10

hello

i have the following rewrite working fine
Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?mystring\.com$ [NC]
RewriteRule .? http://mystring.wordpress.com [R=301,L]


EXCEPT when the request is for one of the paths below
Code: Select all
http://www.mystring.com/forum
http://www.mystring.com/forum/
http://mystring.com/forum
http://mystring.com/forum/


presumably because the folder "forum" exists in the apache wwwroot.

how would i make it always redirect (even if i have to manually code "forum" in a condition) ?

thanks in advance.
Tim Clark
crashnet
 
Posts: 10
Joined: 17 Oct 2007 19:39

Re: Redirect ANY request to root of diff domain

New postby crashnet » 29 Jan 2009 00:42

could it be that i actually found something mod_rewrite can't do?!

thanks in advance
Tim Clark
crashnet
 
Posts: 10
Joined: 17 Oct 2007 19:39

Re: Redirect ANY request to root of diff domain

New postby miels » 03 Feb 2009 12:09

I'd say something like this:
Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?mystring\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/forum/.* [NC]
RewriteRule .? http://mystring.wordpress.com [R=301,L]


PS: htaccess defaults to an AND statement when you use multiple conditions.
miels
 
Posts: 3
Joined: 03 Feb 2009 11:39

Re: Redirect ANY request to root of diff domain

New postby crashnet » 03 Feb 2009 19:23

hmmm thanks but that didnt work.

i actually have a lot of domains on that server. it would be nice to keep the /forum/ directory inaccessible via every domain BUT the main/public_http root domain, as this folder is meant to be a showing up only via the main domain.

thanks in advance
Tim Clark
crashnet
 
Posts: 10
Joined: 17 Oct 2007 19:39

Re: Redirect ANY request to root of diff domain

New postby crashnet » 14 Feb 2009 22:54

could someone please point out why i am not getting any help? maybe because you only get love not help on valentine's day?!

TIA!
Tim Clark
crashnet
 
Posts: 10
Joined: 17 Oct 2007 19:39

Re: Redirect ANY request to root of diff domain

New postby htaccess » 04 Mar 2009 08:58

crashnet wrote:how would i make it always redirect (even if i have to manually code "forum" in a condition) ?


Code: Select all
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(.*)\.?mystring\.com$ [NC]
RewriteRule .* http://mystring.wordpress.com [R=301,L]
htaccess
 
Posts: 50
Joined: 28 Feb 2007 17:16

Re: Redirect ANY request to root of diff domain

New postby crashnet » 04 Mar 2009 13:54

htaccess wrote:
crashnet wrote:how would i make it always redirect (even if i have to manually code "forum" in a condition) ?


Code: Select all
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(.*)\.?mystring\.com$ [NC]
RewriteRule .* http://mystring.wordpress.com [R=301,L]


thanks but it still doesnt work... http://mystring.com/forum/ still brings up the forum instead of the 301 to wordpress.
Tim Clark
crashnet
 
Posts: 10
Joined: 17 Oct 2007 19:39


Return to Redirect or Rewrite Questions