Redirect all hosts which are NOT a particular host

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 2
Joined: 22 Aug 2012, 13:38

Redirect all hosts which are NOT a particular host

22 Aug 2012, 13:41

Hi,

How can I redirect all requests to a particular hostname if they came in on anything other than the domain I've chosen?

eg
redirect
examplea.com
exampleb.co.uk
exambled.fr

and have them *all* redirect to example.com? (I do not know all of the domains).

I've tried this:

Code: Select all
# Redirect all domains to main domain
RewriteCond Host: (?!www.\example\.com))
RewriteRule (.*) http\://www\.example\.com$1 [I,RP,L]

... but it doesn't seem to match.

Thanks,
Nick

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Redirect all hosts which are NOT a particular host

23 Aug 2012, 04:01

Please try like this:

[ISAPI_Rewrite]

# Redirect all domains to main domain
RewriteCond Host: (?!www\.example\.com).*
RewriteRule (.*) http\://www.example.com$1 [RP]

User avatar
Posts: 2
Joined: 22 Aug 2012, 13:38

Re: Redirect all hosts which are NOT a particular host

23 Aug 2012, 07:47

Thanks!

User avatar
Posts: 8
Joined: 23 Oct 2012, 23:06

Re: Redirect all hosts which are NOT a particular host

24 Oct 2012, 23:03

This one also helped me. Thanks.

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 11 guests