0

Here is my htaccess content file.

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC]

RewriteRule ([a-z]+)$ astc/accueil.php?page=$1 [L]
RewriteRule ([a-z]+)/([1-9]+)$ astc/accueil.php?page=$1&id=$2 [L]

When I access to a page with one parameter like "localhost/assoc/accueil", I have no problem but for a page with 2 parameters like "localhost/assoc/accueil/2" The CSS isn't applying.

Any idea please ? Thanks.

4
  • how are you loading your css? start the path with a / or use a full http url then it should load at expected. Commented Aug 10, 2016 at 13:08
  • Oh thanks. When I use a full http it works. But I want if possible to do it by another way. I load it with the path " /assets/plugins/... " wich is in the website directory Commented Aug 10, 2016 at 14:01
  • since /assets/.... is not working looks like you'll need to use the full http you can create a variable that holds that address, then use that anywhere you need the links or any resource that way you only have to set it once. Commented Aug 10, 2016 at 14:23
  • Finally I will take that solution. Thank you. :) Commented Aug 11, 2016 at 8:51

2 Answers 2

1

The basic problem is that because rules are evaluated from top to bottom, localhost/assoc/accueil/2 will match the first rewrite rule so the last one never gets applied.

There are a few ways to fix it, but a simple way is:

  1. reverse the order of your rules, so the more specific path occurs first
  2. Replace [L] flags with [END]

The CSS isn't applying.

I don't know what your problem has to do with CSS. Maybe I missed something

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

1 Comment

Sorry for the bad english. I mean CSS don't load. I replace [L] with [END] and it doen't work too. I reverse the order of the 2 rules too.
1

Finally I use @Dave's solution by using full http link. Thanks to all of you.

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.