Forum Moderators: phranque

Message Too Old, No Replies

Redirecting to another server with .htaccess

How do I display pages on www2 when www is requested?

         

atlantic

2:20 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



Hello everyone,

I have two servers, www.mydomain.com (for php) and www2.mydomain.com (ASP pages).

Currently the default page when accessing www.mydomain.com is index.php. I would like any requests for www.mydomain.com/index.php to be shown a page on www2.mydomain.com (with www.mydomain.com still showing in their address bar). Here's what I've tried...

RewriteCond %{HTTP_HOST} ^www.mydomain\.com/index.php
RewriteRule ^(.*)$ www2.mydomain\.com/folder/home.asp [L]

This has no effect, the index.php page is shown and when I delete it I receive a 404 error. Can anybody help?

Thanks

closed

4:06 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



Assuming the directories for www and www2 are on the same server, and that the directory for www2 is folderForWWW2:

RewriteCond %{HTTP_HOST} www\.mydomain\.com [NC]
RewriteRule ^index.php /folderForWWW2/home.asp [L]

atlantic

8:50 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



www and www2 are on two totally separate servers. I tried modifying your suggestion to...

RewriteCond %{HTTP_HOST} www\.mydomain\.com [NC]
RewriteRule ^index.php [www2.mydomain\.com...] [L]

But still no luck.

Monus

9:02 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



I think it's this.

RewriteEngine On
RewriteCond %{HTTP_HOST}!^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www2.domain.com/$1 [R,L]

jdMorgan

9:09 pm on Oct 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



atlantic,

> with www.mydomain.com still showing in their address bar

If you use an external redirect, the above requirement cannot be met using a server-level directive. Solutions include using iframes or using a script to include the remote content in a page on your "public" domain.

Jim