Hello. I have here matured a few questions that do not give rest in recent times. So:

  1. When initially changing the link from "../home.php" to "../home" by the window.history.replaceState () method, the initial state of the URL (i.e. "../home.php") and the subsequent "blinking "when changing to the second state. How to remove it? mod_rewrite or are there alternative options?

  2. When loading new content using AJAX, I change the URL through window.history.replaceState (). Are there any options where the link like "../home" will open the page "../home.php"?

Thanks to everyone who will pay attention to my questions!

    1 answer 1

    This is very stupid do not you think? What is the point in ajax loading, if you still load the page completely? I think it's worth bringing a couple of pieces of code here.

    In general, this is done with the help of mod_rewrite, for this reason, there should be one page, say index.php, it already has case \ if or what your knowledge will be enough for not the static part of the page, let's say:

    < head>< title>я статичСский Ρ‚ΠΈΡ‚ΡƒΠ» странички< /title>< /head> < body> Π― статичСская надпись, ΠΊ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Ρƒ мСню < div id="content"> < ? if(isset($_GET['link'])) include "/pages/" . $_GET['link'].".php"; else include "/pages/home.php"; ?> < /div> Π― статичСский ΠΏΠΎΠ΄Π²Π°Π». < /body> 

    That is, when you go to the index.php link? About = we get a page from /pages/about.php

    and in order to make http: //moyt.ru/index.php? link = about for example http: //moyt.ru/about/, you will have to tinker with a little bit of rewrite.

    Thus, further work with ike will go more or less normally.

    • Thanks for the answer. And who said that the whole page is reloading? Naturally, only a specific block is overloaded and, on the basis of this block, the URL is changed. So far I have stopped at this method for myself: (for example, there is a call to ./otherpage, which actually does not exist, but only ./home.php#otherpage) 1. Is mod_rewrite ./otherpage transformed into ./home.php? data = otherpage. 2. Pick up JS $ _GET ['data'] 3. I pull Ajax data from otherpage This actually resolved the 2nd question, but the first one has not been solved yet. - xrtdbear