如何在没有.htaccess的情况下将任何子目录重定向到父目录索引?

发布于 2025-01-25 10:53:20 字数 275 浏览 1 评论 0原文

现在,我将任何子目录都重定向到parent目录的index.html

RewriteEngine On
RewriteRule ^(.*)$ index-dev.html 

。 “> https://myserver.com/parent/ * to

有没有任何方法可以在没有.htaccess的情况下进行操作?例如使用JS? 谢谢

Now I am redirecting any subdirectory to the index.html of the parent directory with a .htaccess "RewriteRule"

RewriteEngine On
RewriteRule ^(.*)$ index-dev.html 

https://myserver.com/parent/* to https://myserver.com/parent

Is there any way to do it without .htaccess? For example with JS?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停滞 2025-02-01 10:53:20

好的,我认为也许是不可能的。

我将使用JS URLSearchParams函数获取可变值

  var queryString = window.location.search;
  var urlParams   = new URLSearchParams(queryString);

  var myDIrectory     = urlParams.get('directory');
  ...

OK, I see maybe is not possible.

I am going to use the JS URLSearchParams functions to get a variable value

  var queryString = window.location.search;
  var urlParams   = new URLSearchParams(queryString);

  var myDIrectory     = urlParams.get('directory');
  ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文