Forum Moderators: phranque

Message Too Old, No Replies

Redirect but not rewrite

         

scarevil

4:36 am on Apr 4, 2005 (gmt 0)

10+ Year Member



Hello,

I have the following in .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^my\.anotherdomain\.com
RewriteRule (.*) /subdir/ [R=301,L]

But this shows [maindomain.com...] in the address bar. Is there a way to keep the [my.anotherdomain.com...] in the address bar, but point to [maindomain.com...] [my.anotherdomain.com...] DNS points to IP of maindomain.com. HTTP_HOST contains my.anotherdomain.com.

Thank you,
JC

jdMorgan

7:19 pm on Apr 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JC,

Welcome to WebmasterWorld!

Changing the code to do a rewrite instead of a redirect, and adding a RewriteCond to prevent looping:


RewriteEngine on
RewriteCond %{HTTP_HOST} ^my\.anotherdomain\.com
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteRule (.*) /subdir/$1 [L]

Jim

scarevil

3:54 am on Apr 5, 2005 (gmt 0)

10+ Year Member



That's exactly what I needed. Thank you.