Manager - Product Development

Standard Reporter 11th Feb 2019 12:22:40am
Photo by nanapoku on Unsplash

In my new CI project, I am getting the following error every time I try to access any URL other than the base url and the base url /index.php. For example, if I'd like to access the "about" page:
Not Found
The requested URL /my_base_url/about was not found on this server.
This is what my routes.php file looks like:
$route['default_controller'] = "base";
$route['about'] = "base/about";
$route['404_override'] = '';
I've triple checked my Base controller and it definitely has an about method (which loads an existing "about" view).
Here's my .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
And here's a few things I've set in my config.php file:
$config['base_url'] = 'http://localhost/my_base_url/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
What am I doing wrong? Any help much appreciated!
php .htaccess codeigniter routes
shareimprove this question
asked Oct 14 '13 at 18:32
add a comment
2 Answers
The htaccess file should be in the my_base_url directory, and you should include a rewrite base:
Options FollowSymLinks
RewriteEngine on
RewriteBase /my_base_url/
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
shareimprove this answer
edited Oct 14 '13 at 19:29
answered Oct 14 '13 at 18:36
Jon Lin
I tried this, but then got "Forbidden You don't have permission to access /my_base_url/ on this server." (I checked the permissions on that directory though, and I should be able to view it!) – anniebabannie Oct 14 '13 at 18:50
@anniebabannie Are you sure index.php is one of the files in the DirectoryIndex list? Are you sure the htaccess file is actually getting read (and you have mod_rewrite loaded)? – Jon Lin Oct 14 '13 at 18:52
I checked my httpd.conf file and yes, index.php is listed. I tested to see if the htaccess file was getting read by putting in gibberish (resulted in Internal Server Error – so yes it IS being read), and yes mod_rewrite is being loaded. – anniebabannie Oct 14 '13 at 19:13
@anniebabannie try checking your error logs, it should give you a reason why it returned a 403 Forbidden (either can't access, or configuration disallows, etc.) – Jon Lin Oct 14 '13 at 19:16
I found this "[Mon Oct 14 12:22:54 2013] [error] [client ::1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden" – I am not used to debugging apache server errors, where should I look to fix this? – anniebabannie Oct 14 '13 at 19:25
show 4 more comments
If you use Apache, take a look in config file.
LoadModule rewrite_module modules/
AllowOverride All
shareimprove this answer
answered Oct 14 '13 at 19:00
Yep, both of those lines are in my httpd.conf file. I tried what Jon Lin (below) suggested but now I'm just getting "Forbidden You don't have permission to access /my_base_url/ on this server." – anniebabannie Oct 14 '13 at 19:17