Can I rewrite a URL without redirecting?

So, I learned from this handy guide on how to use .htaccesspretty URIs to redirect, such as foobar.com/baz, to the specific content that might be attached to foobar.com/bazheader345.php?user=baz.

What if I would like to do the opposite? My bindings are static, but I have a lot of content in different files, and none of them have a particularly beautiful name. Let's say I have a page in foobar.com, called 123.html, and I want the location bar to remain http://foobar.com, despite the navigation between the files that the user makes.

Can this be done by changing to .htaccess? Or just javascript?

If possible, will this affect the state of the browser history?

+3
source share
2 answers

It is really easy to do with HTML frames . Say your home page http://example.com/index.html. Save index.htmlas home.htmland save something like the following in index.html:

<html>
  <head>
    <title>Website title</title>
  </head>
  <body>
    <iframe src="home.html" width="100%" height="100%" frameborder="0" scrolling="no" />
  </body>
</html>

If you do not want to rename the original home page, you can use the DirectoryIndexdirective in your .htaccessfile instead . Just save the code above, say, frame.htmlchange home.htmlto any file name your index is in, and add:

DirectoryIndex frame.html

to your .htaccessfile.

, 10 , . , ( , ).

:

+2

, .... URL- .

URL- URL-, .

+2

Source: https://habr.com/ru/post/1763724/


All Articles