Erik
Erik

Reputation: 20722

Mod Rewrite: How do you rewrite out of the URL's home directory?

I have a directory structure on our VPS like this:

/www
  /site_one
  /site_two

And going to www.siteone.com brings you to /www/site_one/ on the server. I'd like to use mod_rewrite to point a request for www.siteone.com/thing/ to the directory /www/site_two/thing.

I've tried a basic rewrite like:

RewriteRule ^page.html$ /www/site_two/new_page.html

but / refers to /www/site_one/

Is there a way to get it to serve the page from the directory I'd like?

EDIT

To answer the questions below:

@Ignacio I'm not sure if I left anything important out. Brand new to mod_rewrite.

@outis: Yes both sites are virutal hosts. www.site_one.com is mapped to /www/site_one/ and www.site_two.com is mapped ot /www/site_two

Upvotes: 0

Views: 343

Answers (1)

outis
outis

Reputation: 77420

Give a full URL, which implicitly redirects:

RewriteCond %{HTTP_HOST} (.*\.)site_one\.com$
RewriteRule ^/?(thing(/.*)?) http://%1site_two.com/$1

To achieve this without redirection, the documents in /www/site_two must be accessible via URLs in the site_one.com domain; a symlink from /www/site_one/site_two to /www/site_two might do it.

Upvotes: 1

Related Questions