我是CodeIgniter的新手,我试图弄清楚为什么我在codeigniter网站和SO这里都看到的标准方法不适用于我从我的项目中的url中摆脱index.php。无法摆脱CodeIgniter中的url index.php
我运行CentOS的,和路径,以我的项目是这样的: 的/ var/www/html等/ myproject的
我已经确定mod_rewrite已在httpd.conf由经检查的phpinfo启用()
我.htacess文件看起来像这样:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myproject/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我的config.php文件看起来像这样(我自己也尝试PATH_INFO和REQUEST_URI为uri_protocol):
$config['base_url'] = 'http://localhost/myproject/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
我的routes.php文件是这样的:
$route['default_controller'] = "site";
$route['404_override'] = '';
$route['site/price/(.*)'] = "site/price/$1";
为现场控制器的价格走势的签名是这样的:
public function price($a, $b, $c) {
//code
}
当我去
http://localhost/myproject/index.php/site/price/32137/2/1
的价格功能已成功达成,但是当我尝试
http://localhost/myproject/site/price/32137/2/1
我得到一个错误页面,指出
The requested URL /myproject/site/price/32137/2/1 was not found on this server.
我缺少的东西? 在此先感谢
编辑: 如果有任何帮助,我可以到我的项目的网站/索引方法只有url:localhost/myproject但其他任何操作都不可访问。
重复。 [http://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2](http://stackoverflow.com/questions/5155333/remove-index-php-from-url- codeigniter-2) –
它不是重复的。它是相似的,但没有任何线程为我工作。 – user3163245