So I've currently got all my URL's redirecting to index.php with this in my .htaccess:
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
However, I need URLs such as http://localhost/Portfolio/Serene/Assets/css/style.css
to not redirect, but I'm not sure how?
I'd really appreciate any help,
Cheers.
EDIT: Alternatively, I could tell the htaccess to not redirect any .js, .css, image files, etc, but again, I'm not too sure how to do this? Thanks!
EDIT2: I could also redirect anything ending in a .php or a path (such as /Portfolio/) to index.php, I have a feeling this may be easier.
EDIT3: Success, final code:
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT} !-f
RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|flv|xml)$ index.php [QSA,L]
Here's a another way to do it:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
images, robots.txt won't be rewritten to index.php. Just add your directories/files.
Hope that helps!
This will rewrite requests for any files that don't exist on the server to index.php:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With