1

When I don't edit my .htaccess file, my image path reads something like: http://this.website.com/codeigniter/inc/images/logo.jpg.

However, as soon as I add this code into the .htaccess file:

RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.+)$ index.php?$1 [L]  

(to remove the index.php from the URL), I get 404 error, even with the exact same path.

How do I remove index.php and still have access to my images?

1 Answer 1

1
RewriteEngine On
RewriteCond $1 !^index\.php [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?$1 [L]

The two new RewriteConditions would exclude existing directories and files (and so images) from redirection.

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

1 Comment

EDIT! This works perfectly! Just needed some time to update. Thanks for your help!

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.