I have many files including images, php& js scripts and subfolders.
I need to redirect to index.php for any uri using .htaccess.
for example:
www.example.com/test should be redirect to index.php
But images should not be redirected to index.php. Instead it should be printed directly in browser.
For example:
www.example.com/sample.jpg should display sample.jpg.
I am using following codes in .htaccess code:
RewriteEngine On
RewriteRule ^(.*)$ index.php
Can someone explain how to allow image to display?
Add conditions before your rule to skip image/css/js filesdirectories:
RewriteEngine On
RewriteRule !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ index.php [L,NC]
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