2

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!

2 Answers 2

1

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]
Sign up to request clarification or add additional context in comments.

9 Comments

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 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)?
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 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.)
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?
|
0

If you use Apache, take a look in config file.

LoadModule rewrite_module modules/mod_rewrite.so

AllowOverride All

1 Comment

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."

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.