How to keep the url fixed?

Asked

Viewed 776 times

5

I’m using the mod_rewrite to rewrite the url, but I would like to leave it fixed, example:

www.meusite.com.br/index.html
www.meusite.com.br/produtos.html
www.meusite.com.br/contato.html

Ficar apenas:
www.meusite.com.br

How can I do this ?

  • 2

    There are several ways to do it, but in all of them you will have to have either the page or the parameter in the url... And another if it is a site that you are doing and want google to do the indexing not recommend using only 1 url

  • 1

    @Jhonatansimões, it is not a site, it is a system, so it is not interesting to index, You could put an answer with the ways to solve this problem, pros and cons of them will be welcome too.

  • A suggestion would be to save and create logic in the session this information, but I will expect a response from someone with experience. Favorite here, good question

  • I think then that rewrite mode is not the solution. You can use ajax to load the pages by not changing the url as there is no redirection. As my answer escapes the question, if you want I can post the code...

1 answer

2


As @Jhonatan Simões said, you can use Javascript for this. You must place a div, which will be the whole body of the main page and use the jQuery load. Google has a multitude of examples, but to make it easier: https://stackoverflow.com/questions/4011191/help-with-jquery-load.

In order for the system to know which page it should load, you have to pass the page url by parameter. Use the POST method, since you want to leave the address bar "clean".

If you don’t want all this junk, use some .htaccess. It won’t look totally like you want, but it will help a lot.

Another tip is: instead of passing parameters by GET (it will get ugly in the url) and POST (it will give problem if give F5 or turn the page), passes the necessary information by session variables, cookies or even Hidden input. With this, you can leave the url like this: www.meusite.com.br/page.

  • Always remember that when using Javascript you are depending on the collaboration of the user, since this can be easily disabled in the browser.

  • I agree. I don’t really like doing that kind of thing. If it were me, the system would only use Javascript for form validations and database requests without having to reload the page. Because if the user gives an F5 or goes back to the page, it’s already getting boring to use.

  • I believe then that if this is the only possible solution it will not be feasible for me, +1

  • I think the best way is still via ajax, so you would browse the pages without reloading and changing url.

  • If you don’t want all this junk, use some of the .htaccess. It won’t stay totally as you want, but it will help a lot. Another tip is: instead of passing parameters by GET (it will get ugly in the url) and POST (it will give problem if give F5 or turn the page), passes the necessary information by session variables, cookies or even Hidden input. With this, you can leave the url like this: www.meusite.com.br/page.

  • However, if you are still going to use ajax to load the pages, you may not be able to work on the site’s SEO, where it would be difficult for search engines to find your site... there is this though.

  • @Andrébaill About SEO issues were explained in the comments of the question

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.