nick
nick

Reputation: 3259

HTACCESS line preventing loading CSS

Rapid question, I'm using this line:

RewriteRule ^([^/]+)/? index.php?url=$1 [L,QSA]

which I took from another post and now my CSS file won't show anything.

This is the structure:

.
+-- .htaccess
+-- assets
|   +-- style.css
|   +-- images
+-- index.php

And there are other files but they're irrelevant.

Upvotes: 0

Views: 30

Answers (1)

anubhava
anubhava

Reputation: 786091

You are missing 2 things:

  1. No $ anchor in your regex pattern
  2. RewriteCond` to skip existing files and directories

Replace your code with this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ index.php?url=$0 [L,QSA]

Also if you are using relative paths for your css/js/images then you can add this just below <head> section of your page's HTML:

<base href="/" />

so that every relative URL is resolved from that base URL and not from the current page's URL.

Upvotes: 2

Related Questions