Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
can';t使用.htaccess删除index.php_.htaccess_Codeigniter - Fatal编程技术网

can';t使用.htaccess删除index.php

can';t使用.htaccess删除index.php,.htaccess,codeigniter,.htaccess,Codeigniter,我已经安装了codeigniter,我想在访问localhost/aplication/index.php时从url中删除index.php。我已经在httpd.conf en中设置了uncomment mod_rewrite.so,这是我的.htaccess文件: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.ph

我已经安装了codeigniter,我想在访问localhost/aplication/index.php时从url中删除index.php。我已经在httpd.conf en中设置了uncomment mod_rewrite.so,这是我的.htaccess文件:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
当我从localhost/aplication/index.php/data/users/12访问url,但不使用此url localhost/aplication/data/users/12时,它会成功


如何修复此问题???

检查您的配置文件应该有一行内容:

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

您可以将此变量设置为“”或完全注释掉这一行,无论哪种方式,这都是从codeigniter URL中删除index.php的过程的一部分。

请尝试跟随此页了解。你的规则看起来是正确的,但我对正则表达式很糟糕


需要研究的一些事情是使用phpinfo()检查mod_rewrite是否可用;。该链接中的第三步还讨论了使用a2enmod启用mod_重写。并确保重新启动Apache。

这就是删除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';
你的virtualhost配置了吗?