unknowdev
unknowdev

Reputation: 33

add .htaccess a trailing slash and css got awful

I'd like to put a trailing slash to my url with .htaccess

My .htaccess is

        RewriteEngine On
        RewriteBase /
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
        RewriteRule ^ %1 [R=301,L]
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME}.php -f
        RewriteRule ^(.*?)/?$ $1.php [NC,L]

When I try to use www.example.com/about-us it works fine but when the Url is www.example.com/about-us/ my css url won't load the website get horrible. Sorry for my bad english.

Upvotes: 1

Views: 141

Answers (1)

Panama Jack
Panama Jack

Reputation: 24478

You need to use absolute URL's or use the base tag in the head section of your site after doing those pretty URL rewrites.

With CSS use / before the path.

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

Or you can use the base.

<head>
<base href="http://www.example.com/">
</head>

Upvotes: 1

Related Questions