Friendly url does not accept the slash after the link

1

I have in the .htaccess the following code:

RewriteRule ^([a-z0-9-]+)/?$ categoria.php?key=$1 [NC,L]

It works perfectly, but when I put the bar after the link, it opens the page without the CSS formatting, as if it were opening a new directory. Ex.:

It works:

www.site.com.br / clothing

Does not work:

www.site.com.br / clothes /

How would I have it to accept the bar at the end of the directory?

    
asked by anonymous 08.11.2017 / 19:38

1 answer

1

If your link to css is being searchable relative to the file like this:

 href="css/seu_arquivo.css"

And your files are in the root folder of the directory (probably httpdocs or something) then the file path search occurs as follows:

httpdocs/css/seu_arquivo.css

It happens that when you add the slash, your file that 'links' css understands that you are inside a roupas/ folder, so it looks like this:

httpdocs/roupas/css/seu_arquivo.css

To get around this there are two ways that I know, one is putting the absolute path with the url of your domain:

href="http://meudominio/css/seu_arquivo.css"

Or the best solution is to put the path up a folder level if your files are all in the root folder of your domain like this:

 href="../css/seu_arquivo.css"

Remembering that this is true for all file links ( css / js ) of your site and in some cases in src of images.

    
08.11.2017 / 19:50