地址栏上固定的URL

编程入门 行业动态 更新时间:2024-10-23 23:24:57
本文介绍了地址栏上固定的URL - 只显示基本URL www.mysite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

本文发布于:2023-11-01 11:59:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:栏上   地址   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!