Forward Slash at end of CSS url breaks

I am developing a website and when I put a forward slash /

at the end the URL

CSS file is not readable.


  • This url works fine:

  • This URL ignores the CSS file:

In short, the forward slash ruins the design of the website.

Does anyone know how to fix this problem? I was looking for a solution .htaccess

but it doesn't work.


source to share

4 answers

try including your css file using an absolute path (for example http://...

) or a path starting from your website (for example /css/yourfile.css


otherwise you need to deny (or redirect) requests to index.php/

in index.php

via .htaccess (or server config)



This will remove the trailing slash, excluding root and existing folders.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)(\.php|\.html)/$  /$1$2 [R=301,L]




Just use "/" before setting css location in index.html header.

<link rel="stylesheet" type="text/css" href="/style.css"/>


This way your index.html will look for the file from the root directory.



just add full url of css files

And also use full path for all href links in this php page for example, just don't add <a href="home.html">

instead<a href="http://domain/home.html



All Articles