Evil_skunk
Evil_skunk

Reputation: 3382

htaccess Rewrite - completely different path

I have the follwing htaccess Rewrite Problem:

I have a domain like www.example.org and the files are in /var/www/www.example.org/

Now I need a rewrite for every Site in www.example.org/b/w/ to /var/www/www.anothersite.org/b/w/ I dont know exactly how I can do this, is this possible?

Thanks for your help

Upvotes: 1

Views: 85

Answers (2)

Chris Clower
Chris Clower

Reputation: 5104

RewriteEngine On
RewriteRule ^b/([w]+) http://www.anothersite.org/b/w/$1 [L,NC]

That should do it :)

Upvotes: 0

Jon Lin
Jon Lin

Reputation: 143886

You can rewrite outside of your document root, but you can redirect (it will change the URL in the browser's address bar):

RewriteEngine On
RewriteRule ^/?b/w/(.*)$ http://www.anothersite.org/b/w/$1 [R=301,L]

or

Redirect 301 /b/w/ http://www.anothersite.org/b/w/

If you need the address bar to stay the same, you can use mod_proxy if that's enabled:

RewriteEngine On
RewriteRule ^/?b/w/(.*)$ http://www.anothersite.org/b/w/$1 [P,L]

Or if you have access to the server or vhost config, just create an alias:

Alias /b/w/ /var/www/www.anothersite.org/b/w/

Or worst case, just symlink /var/www/www.example.org/b/w/ to /var/www/www.anothersite.org/b/w/

Upvotes: 1

Related Questions