简体   繁体   中英

codeigniter 2.1.3 htaccess not working

I am using apache2 on ubuntu 12.10. but the htaccess is not working and here is my htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /ci/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule mod_security.c>
   SecFilterEngine Off
   SecFilterScanPOST Off
</IfModule>


$config['base_url'] = 'http://localhost/ci/index.php'; 
$config[‘index_page’] = “”;
$config[‘uri_protocol’]  = “AUTO”;


1 http://localhost/ci/index.php/site/about
2 http://localhost/ci/site/about

the first work but i want the second to work any idea how to make it work. thanks

404 Not Found
The requested URL /ci/site/about was not found on this server.

Did you enabled mod rewrite ?

set your htaccess (sample)

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

remove index.php in your config

$config['base_url'] = ''; 
$config['index_page'] = '';

Also allow overriding htaccess in your apache

/etc/apache2/sites-available/default

and edit the file & change to

AllowOverride All

and restart apache

Here is what my setup looks like, and mine works as you like yours to work:

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

config.php

$config['index_page'] = '';
$config['base_url'] = 'http://localhost/icms/';

I think that is all I changed to make mine work.

Hope it helps.

Regards,

Kobus

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM