简体   繁体   English

如何在php中隐藏url?

[英]How to hide url in php?

I am working on site in the php. 我正在php网站上工作。 In this site i have 10 screen shot images with herf tag. 在这个网站上,我有10张带有herf标签的屏幕截图。 When a user click on any image, there should open a new tab with that site but actually showing the url of my site. 当用户单击任何图像时,应该在该网站上打开一个新标签,但实际上会显示我的网站的网址。 Eg : if my site is www.abc.com From this site user will redirected to www.xyz.com. 例如:如果我的网站是www.abc.com,则用户将从该站点重定向到www.xyz.com。 But the url above should www.abc.com. 但是上面的网址应该是www.abc.com。 It will shows all the functionality of xyz.com site. 它将显示xyz.com网站的所有功能。 If anybody knows, plz help me. 如果有人知道,请帮助我。 I have seen that type of functionality somewhere before. 我曾经在某处看到过这种功能。

您可以使用完整的iFrame来做到这一点,但是除非绝对必要,否则这不是您真正想做的事情。

The iFrame solution is very simple and maybe the best one for your problem. iFrame解决方案非常简单,可能是解决问题的最佳方案。

But just to provide another possibility: You could implement a sort of web proxy with the PHP function file_get_contents . 但这只是提供另一种可能性:您可以使用PHP函数file_get_contents实现某种Web代理。 If you do something like that, you eventually have to deal with streams to preserve the context (COOKIES, etc.). 如果这样做,最终将不得不处理流以保留上下文(COOKIES等)。

Finally you will have your own URL (maybe rewritten, to look nice), where the content of the other website is shown (but without correct ajax calls and maybe other issues). 最终,您将拥有自己的URL(可能是重写的,看上去很漂亮),其中显示了其他网站的内容(但没有正确的ajax调用和其他问题)。

您可以使用iframe ...或者.htaccess文件可以满足您的需求。

If I get you right you want to change the browser's adressbar content? 如果我理解正确,您是否要更改浏览器的地址栏内容? You can't do that. 你不能那样做。 I've found this on stackoverflow: 我在stackoverflow上找到了这个:

Modify the URL without reloading the page 修改URL而无需重新加载页面

Use full screen iframe: 使用全屏iframe:

<html>
<head>
<title>full screen iframe</title>
<style type="text/css">
/* Full Screen The Page Fix*/
body { margin: 0; }
</style>
</head>
<body>
<iframe src=".../site.html" style="border: 0; width: 100%; height: 100%">Your browser doesn't support iFrames.</iframe>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM