How can I keep the same URL in the address bar for each page?

I have a site created using Codeigniter where there are many pages and directories.

Say the site name is www.example.com (this is an index page). If the user goes to another page, for example, by clicking the "about" link, how can I make the site name not change in the address bar for all pages?

+6
source share
3 answers

This is a bad idea if nothing else prevents users from adding bookmarks to your site.

There are two ways to do this, however, if you intend to do so (and I really suggest that you go back before it is too late). You can load everything in an iframe:

 <!-- your site might look like this then --> <html> <body><iframe src="http://path.to.your.real.site" /> </html> 

And the src property will direct to another url that actually has all the dynamic urls.

Another option is AJAX. It really is too long and complicated for an example.

+2
source

Not sure about codeigniter bu, you can do it in simple php like this:

  • Your url always displays one "front" php function (perhaps even "index.php").
  • In your page navigation you always "POST" from the form. Never use "href ="
  • In FORMS, you have several hidden fields that record the current and requested pages.
  • When your php facade starts, you look at the fields of the "current" and "requested" forms and call the appropriate code to display the "requested" page.

Alternatively, you can use a cookie instead of hidden form fields and some simple javascript to set the value of the โ€œrequestedโ€ cookie.

0
source

Use FRAMESET OR Use Ajax

 <FRAMESET ROWS="100%,*" BORDER=0 FRAMEBORDER=0 FRAMESPACING=0> <FRAME NAME="top" SRC="/Login .aspx or .php" NORESIZE> </FRAMESET> 
0
source

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


All Articles