URL hiding in PHP

2019-06-02 14:00发布

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?

标签: php url
3条回答
劳资没心,怎么记你
2楼-- · 2019-06-02 14:31

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.

查看更多
叛逆
3楼-- · 2019-06-02 14:49

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

查看更多
走好不送
4楼-- · 2019-06-02 14:55

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

查看更多
登录 后发表回答