我需要显示在地址栏只是我的网站的URL的第一部分上。
I need to show on the address bar just the first part of the url of my site.
例如对于名称的任何页面像
For example for any page with name like
www.mysite/mypage.php 或一切
我只希望看到 www.mysite 在浏览器的地址栏上。
I want to see just www.mysite on the address bar of the browser.
这可怎么实现?
我试图与Apache 重写规则,但没有结果。
I tried with apache RewriteRule but with no result.
推荐答案除了是人们实际上是试图使用你的网站一个非常糟糕的主意,有没有办法可以做到这一点在服务器端,因为服务器需要知道哪些页面被访问 - 这是一个URL是。你所寻找的是让它的显示给用户的,他们仍然在同一个URL。
Apart from being a really bad idea for people actually trying to use your site, there is no way you can do this on the server side, because the server needs to know which page was accessed - that's what a URL is for. What you are looking for is to make it appear to the user that they are still at the same URL.
如果你把你的整个网站在HTML框架一帧,或大小,以填补浏览器窗口中的iframe这是很容易做到。这确实需要所有的外部链接有目标=_顶,且无需额外的JS人能够摆脱框架并访问页面单独反正。
This is easy enough if you put your entire site in an HTML frameset with one frame, or an iframe sized to fill the browser window. This does require all external links to have target="_top", and without additional JS people can break out of the frame and access the pages individually anyway.
这是另一种方法,这只会在某些浏览器,是使用 history.pushState 伪造地址栏回 / 每次一新的页面加载。
An alternative approach, that will only work on some browsers, would be to use history.pushState to fake the address bar back to / every time a new page loads.
更多推荐
地址栏上固定的URL
发布评论