【发布时间】:2015-07-11 12:34:14
【问题描述】:
如何将所有文件夹重定向到我的 index.html 并确定用户来自哪里。
首先我只有index.html 和.htaccess 文件。
场景:
- 用户点击链接:
mydomain.com/blabla(通常转到 404)
- 网站重定向到用户
mydomain.com/index.html或mydomain.com/index.html?par=blabla
- 在
mydomain.com/index.html中显示警报“来自mydomain.com/blabla”
这可能吗?谢谢。
更新**********
我找到了这样的解决方案。
首先更改.htaccess文件:https://stackoverflow.com/a/21663207/1173413
并使用 alert(window.location); 就像 Polostor 所说的那样。
【问题讨论】:
-
是的,这是可能的,但你有没有尝试过?
-
我在htaccess文件
RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteRule .* /index.html [L,R=302]和alert(document.referrer)index.html文件中写了这个 -
我在想你可以有一个通用的 js 函数,在每个页面的页面加载时,通过传递当前页面的 url 来调用这个通用函数,并在那个通用函数中进行重定向。在重定向时,将重定向页面的 url 作为查询字符串传递并在 index.html 中准备好它
-
问题是我没有 blabla 文件夹,文件夹名称可以由用户更改。我编辑了问题
标签: javascript jquery html