Ukuser32
Ukuser32

Reputation: 2189

Codeigniter giving 404 but htaccess correct

I am using Codeigniter 3 and have the following htaccess file:

RewriteEngine on

# Allow redirect.phps which are setup 
RewriteCond %{REQUEST_URI} register.php
RewriteRule ^/?([A-Za-z]{2})/register.php /redirect.php/$1 [NC,L]
RewriteRule ^/?register.php /redirect.php/uk [NC,L]

RewriteRule ^/?([A-Za-z]{2})/images/(.*)$ /images/$1/$2 [NC,L]

RewriteCond %{REQUEST_URI} !^/images/([^/]+)/ [NC]
RewriteCond $1 !^(index\.php|css|jscript|convert\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I have tested this on http://htaccess.mwl.be/ and the format is correct and I'm told:

Great. But for some reason I'm getting a Codeigniter 404 page?? Surely Codeigniter should never be even seeing my code? If I put a simple hello+exit in my index.php file I can clearly see Codeigniter is being passed the params so what on earth have I done wrong?

Upvotes: 1

Views: 81

Answers (1)

Niranjan N Raju
Niranjan N Raju

Reputation: 11987

Try changing your .htaccess like this.

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

Or this

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

Upvotes: 1

Related Questions