Htaccess accept bar at end

Asked

Viewed 372 times

-1

I would like to know how do I accept my URL bar at the end /, since this way, when I add bar, the images and css are based on the URL with the parameter, generating error in loading.

http://localhost/pagina/index.php?page=minha-ideia
http://localhost/minha-ideia
http://localhost/minha-ideia/

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1
</IfModule>

Finally, I have doubts about how I should get this URL:

$_GET['page']

Should I or should I not validate this URL, or in the manner described, any error is directed to page 404?

http://localhost/minha-idééééé

1 answer

1


In order for the images to work correctly you must modify your HTML code that must be like this:

<img src='nome-da-pasta/imagem.jpg' alt='*'/>
ou
<img src='http://site.com/nome-da-pasta/imagem.jpg' alt='*'/>

You should leave it that way, including the bar:

<img src='/nome-da-pasta/imagem.jpg' alt='*'/>

Both in image and links, leaves the bar as in the example above that will work!

  • What you think about this, get the value per GET, whether or not to validate this URL, or the way described, any error is directed to page 404?

  • The ideal is to validate. Any error using URL friendly is redirected pro 404. As I gave you the example ai will no longer gives CSS errors, vc should put the "/" in all sites that have links.

Browser other questions tagged

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