Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite http://www.example.com -> http://127.0.34.456/dir/dir/dir

Need to get this effect...

         

SWFWizard

1:41 am on May 9, 2005 (gmt 0)

10+ Year Member



Is this even possible with mod_rewrite?

http://www.example.com -> http://127.0.34.456/dir/dir/dir

But it should still display in the address bar: http://www.example.com

Anybody have any ideas on how to implement this in a .htaccess?

[edited by: jdMorgan at 2:34 am (utc) on May 9, 2005]
[edit reason] Examplified. [/edit]

SWFWizard

3:45 am on May 9, 2005 (gmt 0)

10+ Year Member



Ahh...so simple, I forgot FollowSymLinks :(

This is how you do it, to forward to unregistered DNS servers such as home networks and keep the same domain in the address bar. This uses the proxy method.


Options +FollowSymlinks
RewriteEngine On
RewriteRule ^\www.example.com(.*) http://127.0.45.456/dir/dir/dir$1 [P]

After the redirect is made, www.example.com should still be in the addressbar :).

SWFWizard

5:23 am on May 9, 2005 (gmt 0)

10+ Year Member



Another problem with this method. I need to append in the HTTP header request the user's IP address with this mod_rewrite redirect. Currently when you use this method it appends to the HTTP header the IP address of the first domain www.example.com so there are no unique visitors to [ipaddress...]

Where do I put the HTTP_REFERER in this to have the visitor's IP appended to the HTTP header on the redirect instead of the current domain's IP address? :


Options +FollowSymlinks
RewriteEngine On
RewriteRule ^\example.com(.*) http://127.0.45.456/dir/dir/dir$1 [P]

jdMorgan

12:26 pm on May 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The short answer is that you can't change the actual request header. You could, however, pass the information as a query string, and then use a back-end mod_rewrite to put it in a server variable and then write it to the log file using a custom log format. Something like this:

RewriteRule ^example\.com/(.*) http://127.0.45.456/dir/dir/dir/$1?[b]ref[/b]=%{HTTP_REFERER} [QSA,P]

On the back-end:

RewriteRule %{QUERY_STRING} [b]ref[/b]=([^&]+)
RewriteRule .* - [E=[i]fe_ref[/i]:%1,L]
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{[i]fe_ref[/i]}e\" \"%{User-agent}i\""

I haven't tried this, but maybe it'll get you started. See Apache mod_logconfig [httpd.apache.org].

Jim