mod_rewrite - redirecting without changing the URL

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

mod_rewrite - redirecting without changing the URL

Post by nutkenz »

I'm really not sure if this is possible; what I want is to redirect people who visit http://www.source.tld like this;

RewriteEngine on
RewriteRule ^(.*)$ http://www.destination.tld/splash.php$1 [R=301]

But the flaw with this rule is that the URL is also changed. Is it possible to redirect a user without changing the URL and without using a 100% sized frame?

I don't want to use a frame because the splash.php page is supposed to get the referrer etc and store these in a DB. There are a lot of source domains and I don't want to upload a hundred files when anything changes.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Direct them to a script on your server which performs the remote request for them. The problem is you must get the other site's permission, in writing, to pull their information and display it as your own.
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Post by nutkenz »

That seems like an overly complicated solution. Both sites are mine by the way.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Use AJAX to rip content from one and inject into the other...

This cancels any back forward browsing though...I think you can use the hash mark # followed by a unique number though to work around that if needed...

This also will only work in javascript enabled browsers...

HTH
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Post by nutkenz »

Ok, why doesn't the following work?

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !(^87\.244\.[0-2][0-9][0-9]\.[0-2][0-9][0-9]$) [NC]
RewriteRule ^(.*)$ http://www.url.tld/splash.php$1 [R=301,L]

The plan is to NOT redirect anyone in the specified IP range to the splash page...

I checked the Regex using the Regex Coach so that shouldn't be the problem.
Post Reply