leave / at the end of the url

Asked

Viewed 186 times

2

I would like to hide the . php extension of website of all pages and get bar at the end example: www.meusite.com.br/pagina/

I would also like to hide the pages that are like Landing pages, that are like that: www.meusite.com.br/lp/br/rj/exemplo.php

It would have to stay that way: www.meusite.com.br/exempo/ (Obs: would hide lp/br/rj/ )

Anyone can help ?

1 answer

1

This is more than leaving the / at the end and remove the .php. You can try something similar to this Hide domain directory using htaccess or cakephp router

I believe your .htaccess would look like this:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteRule ^(?!lp/br/rj/)(.*)/$ lp/br/rj/$1.php [QSA,L]
</IfModule>

If you want the address http://exemplo.com/contato and http://exemplo.com/contato/ access the same php file, use it like this:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteRule ^(?!lp/br/rj/)(.*)(/|)$ lp/br/rj/$1.php [QSA,L]
</IfModule>
  • It didn’t work, when I click on the "contact" page of the error, should I already put in the <a href="contact/"> header like this?

  • But there is the file in the folder called /lp/br/rj/contato.php? Why this was the understanding of your request @user27508

  • @user27508 I think I understand what you need, I edited the answer, please let me know if anything is missing

  • detail,to work the url rewriting you need to make sure that this enabled mod_rewrite in your apache.

  • 1

    @Gabrielrodrigues the link I posted in the body of the answer has the orientation activate mod_rewrite :)

Browser other questions tagged

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