Welcome Guest, Not a member yet? Register   Sign In
apache mod_rewrite problem: all css/js/images 404
#1

Rather than using  an .htaccess file, I'm trying to get the basic CodeIgniter mod_rewrite files working in my apache conf file. I'm doing this because apache says .htaccess files cause a performance hit.
Quote:You should avoid using .htaccess files completely if you have access to httpd main server config file.

The mod_rewrite section of my apache conf, which is based on the default htaccess file, looks like this:
Code:
        <IfModule mod_rewrite.c>
                RewriteEngine On

                # If you installed CodeIgniter in a subfolder, you will need to
                # change the following line to match the subfolder you need.
                # http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
                #RewriteBase /

                # Redirect Trailing Slashes...
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)/$ $1 [L,R=301,END]

                # Rewrite "example.com" => "www.example.com", leave all other subdomains alone
                RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
                RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [R=301,QSA,END]

                # Checks to see if the user is attempting to access a valid file,
                # such as an image or css document, if this isn't true it sends the
                # request to the front controller, index.php
                # JTA NOTE this is different than default .htaccess file from CI4
                # because it's in the apache conf instead -- THE SLASH BEFORE
                # index.php IS CRITICAL
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ /index.php$1 [L,NC,QSA]

        </IfModule>

Note that the www redirect is a bit different in my case due to different requirements.

This mostly works, but for some reason it also rewrites all of my CSS/JS/images also despite the !-f and !-d rewrite conditions. Can anyone tell me how to modify this so that it prevents rewriting of actual files to the index.php file?
Reply


Messages In This Thread
apache mod_rewrite problem: all css/js/images 404 - by sneakyimp - 02-12-2021, 12:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB