Page 1 of 1

PHP redirect plus masking.

Posted: Tue Sep 28, 2010 11:49 pm
by James01
Hi

Well I have been using a php redirect script where I create a new folder and in the folder paste a index.php file which contains the code for a redirect.

For example http://DomainName/Sub redirects to http://www.yahoo.com using the following code

Code: Select all

<?php
header( 'Location: http://www.yahoo.com' );
?>
First Question:- Is there a way to do it quickly instead of every time having to create new folders and then creating an index file in them?

Second Question:- What code should I insert in the above so that when someone gets redirected he still sees http://DomainName/Sub

I look forward to the help.

Re: PHP redirect plus masking.

Posted: Wed Sep 29, 2010 12:00 am
by twinedev
Question 1, to do it automatically.

Look into using mod_rewrite so that when people go to a place on your server, if it isn't an actual file (or folder), then it will fire a specific script and be passed the actual called page.

Then that script could then take what was actually browsed for, look it up in a database to see where you wanted to redirect them to.

(Sorry, been a long day, to tired to get into details, just giving basics for now).

Question 2, do it and keep the URL the same.

Two methods, one simple, one not so simple.

-Simple method, do a frame, 100%, and call the other page as the source of the frame.
-Complex, write code that does something like curl to grab the source of the page you are wanting them to see. Then you also have to handle the fact that all referenced images/CSS/javascript are on the other server. Also, as soon as they follow a link, unless you mask ALL links as well, you use the URL in the browser.

NOTE: For quest #2, it is recommended that you only do this with sites you have permission to do this with. (ie, I'm sure it was just a sample, but if you were to do this with Yahoo's site, and they find out you are feeding their content as your own domain, they may not like it and you may get a C&D from their (not so) friendly legal henchmen.

-Greg

Re: PHP redirect plus masking.

Posted: Wed Sep 29, 2010 3:41 am
by DigitalMind
Q2. mod_proxy is also able to solve it