URL hiding in PHP

2019-06-02 14:10发布

问题:

How do I display another url or main domain name instead of filename in php? For example suppose I am redirected to file http://example.com/myfolder/test.htm, then instead of specified url I want to display example.com in the address bar for such url. How can it be done?

回答1:

you can do this with .htaccess here is a useful link.



回答2:

Not with PHP, you can use Frames for that, but this isn´t relay a good design I think...



回答3:

This can not be done in php. PHP is server side language and the request sent is from user.

So if you want user to open http://www.example.com and show http://www.example.com/folder/script.php page use URL REWRITE.

But if you want a user who have opened http://www.example.com/folder/script.php to show http://www.example.com in address bar but still show script.php content.

On accessing script.php page redirect to http://www.example.com/ and in your index page check for referrer. If its script.php (within your own domain) just include that page.

It will be a long work but it depends what you need. Its just an idea.



标签: php url