1

This is my current .htaccess

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

Now I want to route all request for js/css to combine.php(for minyfying), so I Tried,

Trial 1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]
RewriteRule ^css/(.*\.css) /library/combine.lib.php?type=css&files=$1
RewriteRule ^js/(.*\.js) /library/combine.lib.php?type=javascript&files=$1

Error : All request(css/js) are routed to index.php

Trial 2

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^css/(.*\.css) /library/combine.lib.php?type=css&files=$1
 RewriteRule ^js/(.*\.js) /library/combine.lib.php?type=javascript&files=$1
 RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]

Error: 500 internal server error

How to accomplish all request(js/css) to go to combine.php, without disturbing the existing rewrite rules ?

2
  • Does /css/foo.css file exist on your server? Commented Jul 27, 2015 at 16:20
  • yup @Starkeen they do exists Commented Jul 27, 2015 at 16:22

1 Answer 1

1

This should work :

 RewriteRule ^css/(.*\.css)$ /library/combine.lib.php?type=css&files=$1 [NC,L]
 RewriteRule ^js/(.*\.js)$ /library/combine.lib.php?type=javascript&files=$1 [NC,L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the reply, still no luck ..all css /js request hitting index.php
What is the url your typing in your browser?
myurl/css/reset.css it taking me to index.php, it seems rewrite is working but when its going to requesting for combine.php, its being routed to index.php
Does this url www.example.com/library/combine.lib.php?type=css&files=reset.css work when you enter it in browser?
it worked bro , my bad .. I gave this <FilesMatch "^(combine\.php)?$"> Allow from All </FilesMatch>

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.