Forum Moderators: phranque

Message Too Old, No Replies

Help me rewriting this URL

         

mr_ranjith

6:18 am on Aug 29, 2005 (gmt 0)

10+ Year Member



I have a file aboutus.html in www.domain1.com

I want to access this file from www.domain2.com

While rewriting, the URL in the address bar should be www.domain2.com/aboutus.html.

jdMorgan

9:30 pm on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mr_ranjith,

Welcome to WebmasterWorld!

In order to answer this question we need to know whether the two domains are hosted in the same machine under the same virtual host, the same machine under different virtual hosts, or on different machines altogether.

Jim

mr_ranjith

4:26 am on Aug 30, 2005 (gmt 0)

10+ Year Member



Hello Jim,

Both the two domains are hosted on two different servers or machines.

I have tried this on .htaccess file in domain1, but no result.

RewriteEngine ON

RewriteCond %{REQUEST_URI} /aboutus.php

RewriteRule ^/aboutus.php$ [domain2.com...]

:(

jdMorgan

1:02 pm on Aug 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In .htaccess, the leading slash will be stripped from the requested local URL-path tested by RewriteRule, so your pattern must be modified:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^aboutus\.php$ https://www.domain2.com/aboutus.php [R=301,L]

Or just

RedirectMatch 301 ^/aboutus\.php$ https://www.domain2.com/aboutus.php

The first code example is for mod_rewrite, while the second uses mod_alias.

You may not need the first line in the mod_rewrite code -- Try it with and without the Options directive.

I note that you're redirecting to a secure connection (https), which also affects the methods you can use.

Jim

mr_ranjith

7:20 am on Sep 1, 2005 (gmt 0)

10+ Year Member



Sorry Jim,

I'm getting a 404 error. I have tried both the methods.

I want to make use of the files in server1(www.domain1.com)

for (ne.domain2.com)server2.

for eg:-

from (ne.domain2.com)server2, if i request

[ne.domain2.com...] the file should be

from server1(http://www.domain1.com/aboutus.html) but the

address bar should show [ne.domain2.com...]

:-(

mr_ranjith

12:25 pm on Sep 1, 2005 (gmt 0)

10+ Year Member



I tried this piece of code

RewriteEngine ON

RewriteRule ^aboutus\.html$ [domain1.com...] [R=301,L]

Redirecting, but the address bar also changes to
[domain1.com...]
i dont want this to happen. I want the address bar to show
[ne.domain2.com...]

:-(

dcrombie

1:09 pm on Sep 1, 2005 (gmt 0)



You can find the documentation for mod_rewrite here [httpd.apache.org]

Your situation is described towards the bottom of that page. The solution being to use an internal proxy:

^localpath(.*) [otherhost...]  [P]

mr_ranjith

6:41 am on Sep 2, 2005 (gmt 0)

10+ Year Member



Thank you dcrombie,

Its working perfectly as i expected.
But if i tried to use

^localpath(.*) [otherhost...] [P]

it throws an internal server error.

How could i do this on secured server?