Reputation: 31
I'm having trouble with my codeigniter mod_rewrite config... Here is my current config:
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^.* https://www.%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent,L]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^.* https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent,L]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ https://%{SERVER_NAME}/index.php/$1 [L]
Please note, that this is not in a .htaccess file, this is in my virtual hosts file.
Accessing example.com rewrites to https://www.example.com and accessing www.example.com redirects to https://www.example.com
But accessing https://www.example.com/login brings up a 404 page...
Thanks
Upvotes: 0
Views: 77
Reputation: 9308
First rule was mostly okay. Second rule was not good, don't know how you weren't getting infinite redirects from it. Third rule had a redundant condition and external redirect format but should be an internal rewrite. You don't need QSA
unless your substitution contains a ?
. Without a ?
the query is automatically appended.
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [R=permanent,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!index.php(?:$|/)).+$ index.php/$0 [END]
Upvotes: 0
Reputation: 381
Codeigniter URL is structured as follows :
Site_URL/Controller/methods
404 Page error occur in the following case :
Upvotes: 1