0

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.

2
  • You shouldn't take any line and just paste it in your environment to see what happens. You should try to write your own. If it doesn't work, then ask for help in SO. This way, you'll learn. Commented Sep 13, 2017 at 14:51
  • I get what it does, I just don't get the regex part and how I can fix it Commented Sep 13, 2017 at 15:02

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.