I was looking for a way to move files from my root folder / to designated folder /newFolder while weeping this change hidden from users, for example, when going to
http://site.com/ABC
I want the browser to display content from
http://site.com/customerPages/ABC
but the client will see the following URL in his browser:
http://site.com/ABC
I’ve tried using RewriteRule but since the folder names aren’t pre-defined I failed to do so. Then I tried using file_get_contents() in my 404 page but it broke all the relative paths.
Finally I used the following code in my 404 page:
// Redirect customers to customers landing pages under /newFolder
if (strpos($message,'newFolder') === false) {
$url = 'http://'.$_SERVER['HTTP_HOST'].'/newFolder'.$message;
echo '<frameset><frame src="/newFolder'.$message.'"></frameset>';
exit();
} else {
// correct the URL - remove the `/newFolder` bit
$message = str_replace('/newFolder','',$message);
}
$message – the requested URI
I know that this solution is dirty, and i would love to improve it. Anyone knows how to?
Are there any problems with my design? are there any issues using frameset to display a webpage?
EDIT
I eventually stayed with my original solution (used the 404 page with frameset) to avoid from creating rules for all of the pages, and there for making the .htaccess heavier.
If You Want have Different URL for Your client
You Can Use This code in htaccess
I Test It In My Web host Work correctly
Sample:
Virtual URL
http://sepidarcms.ir/ABC/Client1/image/logo.png
http://sepidarcms.ir/ABC/Client2/image/logo.png
http://sepidarcms.ir/ABC/Client3/image/logo.png
Real URL For All:
http://sepidarcms.ir/customerPages/image/logo.png
if You Want Can Remove ABC With a Little Change In This code