rewrite http://oscar.foo.org to http://sam.foo.org/oscar

Using a single web hosting account to host multiple sites

rewrite http://oscar.foo.org to http://sam.foo.org/oscar

Postby Guest » Tue Oct 19, 2004 1:31 pm

I have a web server sam.foo.org with DocumentRoot of /htdocs. The DNS record for oscar.foo.org points to the same IP as sam.foo.org. However, I need requests for http://oscar.foo.org to be served via http://sam.foo.org/oscar. I want to put in the mod_rewrite instrucions in a configuration file, not a .htaccess file. What rule will accomplish this and does it need to be within the <Directory /htdocs> </Directory> section or somewhere else in the config file?
Guest
 

Postby phpmaven » Sat Nov 27, 2004 1:26 pm

Put the following into the <Directory> section on your httpd.conf file:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^sam\.foo\.org
RewriteRule ^(.*)$ http://sam.foo.org/ocsar/$1 [R=301,L]

This will check the host for every request and if it isn't sam.foo.org it will do a permanent redirect to http://sam.foo.org/oscar/

If you want the redirect to be transparent to the user, then change [R=301,L] to [L]
phpmaven
 
Posts: 5
Joined: Sat Nov 27, 2004 12:57 pm

Postby clickhereforit » Thu Dec 16, 2004 4:27 pm

Is there anyway to do this using .htaccess? I dont think I have access to httpd.conf on my server.
clickhereforit
 
Posts: 2
Joined: Thu Dec 16, 2004 4:22 pm

Postby Caterham » Fri Dec 17, 2004 7:09 am

The rule should work in .htaccess, too
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 119 guests

cron