Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite 2nd domain points to sub-directory. How to hide?

have 2nd domain point to subdirectory of 1st domain, but not reveal this

         

pHfactor

9:30 pm on Jan 19, 2007 (gmt 0)

10+ Year Member



I know this is a very newbie question, but I couldn't find it with search.

I have a 2nd domain that I'm hosting via a subdirectory of my first domain. My mod_rewrite code is as follows:

RewriteCond %{HTTP_HOST} ^w{0,3}\.2ndDomain\.com$
RewriteRule (.*) [1stDomain.com...] [R,L]

My problem is that the location in the user's browser reads:

[1stDomain.com...]

and I'd like it to read:

[2ndDomain.com...]

How do I do this?
Thanks,

pH

phranque

2:05 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



what i would try first is to fix this in the apache config file instead of using rewrite.
set the DocumentRoot to that subDirectory of the first domain in the VirtualHost section for ServerName www.2ndDomain.com.

use at your own risk...

jdMorgan

2:21 am on Jan 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If modifying your httpd.conf file is not an option, then change your rule from a redirect to an internal rewrite:

RewriteCond %{HTTP_HOST} ^(w{1,3}\.)?2ndDomain\.com$
RewriteCond $1 !^2ndDomain-subDirectory/
RewriteRule (.*) /2ndDomain-subDirectory/$1 [L]

The second RewriteCond is needed to prevent an 'infinite' rewriting loop.

Jim

[edited by: jdMorgan at 2:21 am (utc) on Jan. 20, 2007]