简体   繁体   中英

.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:

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. How I should write .htaccess to remove index.html from the URL. Any help?

Sorry but this is not possible with .htaccess or any other server side solution. 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.

You have to do this on the browser site, in your case with AnuglarJS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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