Sinklar
Sinklar

Reputation: 85

Conditional URL rewriting

How can I use URL rewriting in .htaccess to redirect to different domains depending on the URL?

Examples:

Upvotes: 1

Views: 582

Answers (1)

Martin
Martin

Reputation: 38329

This ought to work if you want to redirect the client:

# http://ONE/ to http://TWO/
RewriteCond %{HTTP_HOST}    =one
RewriteRule ^$             http://two/ [R,L]

# http://ONE/some_content to http://THREE/some_content
RewriteCond %{HTTP_HOST}    =one
RewriteRule ^(.+)$         http://three/$1 [R,L]

If you prefer to proxy the requests, change the R flag to a P instead.

Upvotes: 2

Related Questions