0

So, I've spend hours on this. I cannot figure it out. I've read several message boards and have not got it working.

Here's what I have done:

1) Added a file called ".htaccess" to the folder "/www/site_name". this file contains the following:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

2) changed

$config['index_page'] = 'index.php';

to

$config['index_page'] = '';

3) went through several httpd.conf files changing every possible combination of the lines:

AllowOverride None

to

AllowOverride All

4) enabled the rewrite_module

This is driving me absolutely mad. I've spent literally hours on this.

EDIT: Maybe i'm not setting the right AllowOverride to all. Which one is the right one?

EDIT: I got it working. Thank you to the chosen answer for the help

4
  • Have you restarted Apache since installing mod rewrite? Commented Nov 10, 2011 at 20:55
  • Yes. I restarted after every change. Commented Nov 10, 2011 at 20:59
  • what platform is the server running on? windows,mac or linux? Commented Nov 10, 2011 at 21:01
  • @user821843 Have you changed $config['uri_protocol'] to AUTO in config.php? Commented Nov 10, 2011 at 21:11

1 Answer 1

1

Below is the .htaccess file which I use on my codeigniter installations. Perhaps you could try it out in an attempt to rule out the .htaccess file? If this works then we can add in your other rules if they're really necessary for your situation?

<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?baseurl=$1 [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

The lines below bulk cater for your requirement to allow directories like /images/ and files such as robots.txt etc. If the file or folder exists it wont be rewritten. The application and system directories are protected by the other rules though.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Sign up to request clarification or add additional context in comments.

1 Comment

So, I'm definitely on the right track now. My htaccess file ONLY contained what I have listed. It not is exactly like yours. But. Now, if i go to localhost/mysite it brings me to the sites home, which is correct. but if I go to localhost/mysite/faq (which exists), it brings me to the localhost main page

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.