地址栏上固定的URL - 只显示基本URL http://www.mysite.com [英] fixed url on address bar - show only base url http://www.mysite.com

查看:165
本文介绍了地址栏上固定的URL - 只显示基本URL http://www.mysite.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示在地址栏只是我的网站的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

http://www.mysite.com/mypage.php
一切

我只希望看到 http://www.mysite.com 在浏览器的地址栏上。

I want to see just http://www.mysite.com 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.

这是另一种方法,这只会在某些浏览器,是使用<一个href=\"https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history?redirectlocale=en-US&redirectslug=DOM%2FManipulating_the_browser_history\"相对=nofollow> 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 - 只显示基本URL http://www.mysite.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆