0

first, i'm trying to find an answer to this like 3 nights :) If there's answer of this, i couldn't find or understand.

My question is simple:

I want to split get parameters with slashes. And use this globally in my script.

in htaccess, i wrote this;

RewriteRule ^(.*)/(.*) index.php?param1=$1&param2=$2 [NC,QSA,L]
RewriteRule ^(.*) index.php?param1=$1 [NC,QSA,L]

but this blocks (or sth like that) css files. when browser loads page, css file links looks normal but browser can't reach them (because of htaccess gets directories as parameters)

Thank you for your helps

edit: my full .htaccess:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f


RewriteRule ^(.*)/(.*) index.php?param1=$1&param2=$2 [NC,QSA,L]
RewriteRule ^(.*) index.php?param1=$1 [NC,QSA,L]

2 Answers 2

2

Make sure both your rules look like this. Conditions only work for the first rewrite rule following them.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*) index.php?param1=$1&param2=$2 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?param1=$1 [NC,QSA,L]

Also use absolute paths for your CSS files or put a / before the file path.

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

1 Comment

I will :) it says i have to wait for 2 more minutes.
0

By putting this above the rules:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

It checks if the files already exist (eg the CSS files) and therefore won't try to rewrite or redirect them.

2 Comments

i use them at begining.
This way the conditions only apply to the first rule. New rule, new conditions. You will have to duplicate them for the second one.

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.