【问题标题】:Open URL but point to main directory打开 URL 但指向主目录
【发布时间】:2015-12-14 16:43:55
【问题描述】:

我打算用 AJAX 做一个网站。

目前我用“#”更改我的主要内容:

例如example.com/#home --> example.com/#site1 我设法在主题标签更改时更改内容。

但现在我想使用我从谷歌知道的方法。 example.com/home/ --> example.com/site1/

到目前为止,我知道如何在不重新加载页面的情况下更改 URL。 (Modify the URL without reloading the page) 我的问题是如果用户重新加载网站或使用导航按钮,他将登陆example.com/site1/index.php 而不是example.com/index.php

但是将数据 (site1) 发送到脚本很重要。

希望你能理解我的问题。

【问题讨论】:

    标签: javascript php jquery ajax hashtag


    【解决方案1】:

    无论网址是什么,您都需要在服务器端(例如.htaccess)返回您的 index.php。

    请参阅此处了解可能的解决方案:https://stackoverflow.com/a/8392502/1030527

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-27
      • 2016-04-18
      • 1970-01-01
      • 2016-11-19
      • 2017-05-06
      • 1970-01-01
      • 2021-12-24
      • 1970-01-01
      相关资源
      最近更新 更多