After viewing another post earlier in the HTML5 History API and reading a tutorial in Mozilla , I was able to implement a basic working demo to use this API to allow the URL to “rewrite” without reloading the page and without using a hash.
My question is: Let's say you have a user who comes to the page, clicks on one of these links, which uses the history API to write a new URL. Then the user enters the page on the page. Now I assume that there will now be bookmarks of the rewritten URL. So, when the user returns in a couple of days or something else and tries to go to the bookmarked page, will he return 404? So how can you somehow implement a way to solve it?
The URL I'm rewriting is supposed to point to a nonexistent location.
, , pushstate. , , , artist.php. , . , "" , artist.php? Artist = travel
, , , ajax (artist.php? artist = travel & ajax = true). "" artist.php? Artist = , , , .
, - URL-, -.
. URL- .
: pushstate HTML5, , , 404.
jst pushstate , , , JS .
The easiest solution is to add a rewrite rule to your Nginx or Apache server to internally rewrite all calls to the same index.html page. The browser believes that it is given a unique page when it is actually the same page:
Apache (in your vhost if you use it):
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule>
Nginx
rewrite ^(.+)$ /index.html last;
You would of course add some JS logic to display the correct content. In my case, I use Backbone routes that easily handle this.
Source: https://habr.com/ru/post/1791785/More articles:ASP.NET MVC Reading files from a server - asp.net-mvc.Net & WCF - How to create REST instead of SOAP? - jsonImplicit conversion from array to list - scalaobtaining permissions that are usually locked at the system level on root devices - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1791784/ivy-appears-to-fetch-javadoc-jars-only&usg=ALkJrhiDLnfjP_U-xfGx2NEq_DVDc4y3kQHow to load Core Data to a view other than RootViewController? - iphoneКак я могу запустить Oracle XE только на локальном хосте? - oracleWhat is the best toolkit for building an application that includes an embedded web server? - phpHow is the Dijkstra algorithm better than the A * algorithm for finding the shortest path? - algorithmCheck the status of the windows of the external program, simulate this state - c #All Articles