2012-09-21 59 views
0

我已经安装codeigniter,我想从url删除index.php当我访问localhost/aplication/index.php。我已经设定取消注释mod_rewrite.so从httpd.conf中连接这是我的.htaccess文件:无法删除index.php与.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

的更迭,当我存取权限从本地主机/ aplication/index.php文件/数据/用户/ 12而与此网址url localhost/aplication/data/users/12。

我该如何解决这个问题?

+2

请问您的虚拟主机配置[允许覆盖](http://httpd.apache.org/docs/2.2/mod/core.html#AllowOverride)? – complex857

回答

1

尝试关注关于codeignitor pretty urls的网页。你的规则看起来是正确的,但是对于正则表达式我很糟糕。

有些事情要检查是否mod_rewrite可通过使用phpinfo();.第三步,在该链接中讨论使用a2enmod启用mod_rewrite。并确保你重新启动Apache。

0

检查您的配置文件中应该有这样一行:

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

您可以设置这个变量只是“”或者你可以完全注释此行了,无论哪种方式,它是过程的一部分从codeigniter网址中删除index.php。

0

你这是怎么删除的index.php:

htaccess文件在根文件夹:

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

管理一些静态页面,如:example.com/about,example.com/contact ,example.com/terms等

得配置路由文件并编辑:

//the controller that will be when it is exampl.com 
$route['default_controller'] = 'YOUR_MAIN_CONTROLLER_NAME_HERE'; 
//I creted this for pages that are created dynamically or for displaying error when I want 
$route['404_override'] = 'friendlyPages';