简体   繁体   English

.htaccess重写规则,以删除网址之间的index.html

[英].htaccess rewrite rule to remove index.html inbetween the url

In my application, I will be redirect from a website to open an url link as below: 在我的应用程序中,我将从网站重定向到打开一个URL链接,如下所示:

https://[site]/index.html#/Login

In that url site I'm using AnuglarJS, now i need to redirect like ' https://[site]/#/Login ' but I didn't work. 在该网址站点中,我使用的是AnuglarJS,现在我需要像' https:// [site] /#/ Login '这样的重定向,但是我没有用。 How I should write .htaccess to remove index.html from the URL. 我应该如何编写.htaccess以便从URL中删除index.html。 Any help? 有什么帮助吗?

Sorry but this is not possible with .htaccess or any other server side solution. 抱歉, .htaccess或任何其他服务器端解决方案无法实现。 The reason is very simple. 原因很简单。 A basic URL is build like this: 基本网址的构建如下:

scheme://host/path?query#fragment

So in your case this 所以在你的情况下

scheme   => https
host     => site
path     => index.html
query    => N/A
fragment => /Login

The point is, that the fragment is nothing a browser ever sends to the server. 关键是,该片段不是浏览器发送到服务器的任何内容。 So in your case, from the server point of view you have requested: 因此,从服务器的角度出发,您已请求:

https://[site]/index.html

The server can redirect or rewrite it to https://[site]/ but not to https://[site]/#Login , at least not if you want to use different kinds of fragments like #/Login , #/Logout , #/SomePage , etc. what I assume. 服务器可以将其重定向或重写到https://[site]/但不能重定向到https://[site]/#Login ,至少如果要使用#/Login#/Logout等不同类型的片段,则不能, #/SomePage等等。

You have to do this on the browser site, in your case with AnuglarJS. 对于AnuglarJS,您必须在浏览器站点上执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM