Forum Moderators: phranque

Message Too Old, No Replies

A Record redirect with. htaccess

         

shoreham1

7:52 am on Apr 12, 2008 (gmt 0)

10+ Year Member



Hi,
I need some advice on how to accomplish this:

1. I have a sub-domain on my host called store.example.com that points to an IP address of another site on the same host called www.other-domain.com.

2. The store.example.com sub-domain works, however just shows the words "FUSION ROOT".

3. I need to firstly get the store.example.com sub-domain to actually see www.other-domain.com files instead of FUSION ROOT.

4. Secondly I need to get the store.example.com to redirect to www.other-domain.com/store/ BUT still show store.example.com in the address bar.

As I am quite new to .htaccess I;m not even sure that this is possible and would appreciate any advice or thoughts anyone may have.

Many thanks,

Pete

[edited by: jdMorgan at 1:32 pm (utc) on April 12, 2008]
[edit reason] examplified domains [/edit]

shoreham1

11:00 am on Apr 12, 2008 (gmt 0)

10+ Year Member



Hi,
I forgot to add that I've tried the following in the root of www.other-domain.com but it gives me a 500 internal server error:

RewriteEngine on

RewriteCond %{HTTP_HOST} store.example.com$ [OR]
RewriteCond %{HTTP_HOST} www.store.example.com.com$
RewriteCond %{HTTP_HOST} !www.example.com$
RewriteRule /(.*)$ http://www.example.com/store/ [L,R=301]

RewriteRule ^(.*)$ www.other-domain.com/store/$1 [L]

Any thoughts or ideas ?

Many thanks

Pete

[edited by: jdMorgan at 1:33 pm (utc) on April 12, 2008]
[edit reason] examplified domains [/edit]

jdMorgan

1:47 pm on Apr 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



4. Secondly I need to get the store.example.com to redirect to www.other-domain.com/store/ BUT still show store.example.com in the address bar.

A redirect involves the client, and will change the address bar. An internal rewrite changes the file path without involving the client, and the address bar is therefore unaffected. But since a rewrite is internal to a server, it cannot be used to access a different domain.

Your remaining choice is to reverse-proxy requests from example.com to other-domain.com using Apache mod_proxy or mod_rewrite's [P] flag. This will pass requests from the example.com domain over to the other-domain.com server without changing the client's address bar. However, all requests in the logs (and stats) of the other-domain.com server will appear to come from the example.com server's IP address unless you modify both servers' configuration by adding "x-forwarded-for" headers on the front-end and use a custom logfile format on the back-end to show the forwarded-for IP address instead of the front-end machine's IP address in the logs.

Note that your HTTP_HOST patterns should probably be start-anchored, and the literal periods (full stops) should be escaped -- i.e. "." should be replaced with "\." in regex patterns to match a literal period.

The first stop when you get a 500-Server error should be your server error log file. What does it say is the problem?

Jim