Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.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
从url中删除index.php在localhost上起作用,但在联机情况下不起作用_Php_Codeigniter_Url_Routes - Fatal编程技术网

从url中删除index.php在localhost上起作用,但在联机情况下不起作用

从url中删除index.php在localhost上起作用,但在联机情况下不起作用,php,codeigniter,url,routes,Php,Codeigniter,Url,Routes,我使用codeigniter处理PHP项目,从本地URL中删除index.PHP,这是我的.htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$1 [PT,L] 当我上传项目在线路由根本不起作用,我需要用普通url而不是路由设置index.php 例如,我必须写索引,而不是写索引 index.php

我使用codeigniter处理PHP项目,从本地URL中删除index.PHP,这是我的.htaccess

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
当我上传项目在线路由根本不起作用,我需要用普通url而不是路由设置index.php

例如,我必须写索引,而不是写索引 index.php/product\u management\u controller/index

如果我写索引,即使我将路由更新为包含index.php,它也不起作用!!这意味着路线也不起作用

我现在的路线是 $route['index']=产品管理\控制器/索引

下面是我在config.php文件中设置的一些内容:

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
解决办法是什么


它可以在本地正常工作

托管服务器需要允许.htaccess文件,在Apache配置中需要添加:

允许超越所有

到您的Apache配置。然后重新启动Apache服务器

你也可以试试

选项+以下符号链接-多视图 重新启动发动机 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D
RewriteRule.*index.php/$1[PT,L]

有一个关于从codeigniter的url中删除index.php的文档


顺便说一句,根据注释,您在godaddy共享服务器上,并且您没有访问apache配置文件的权限,但好消息是,您不必担心默认情况下“重写模式”为“打开”:

我从godaddy托管服务器,我是否有权访问Appache配置文件?它是VPS还是共享托管?我不知道,实际上,我去godaddy托管并从那里预订服务器!检查我的答案,我已经添加了一些。如果您不知道您在共享上的权限,并且他们可能已经允许您访问,请尝试在.htaccess的顶部添加选项+FollowSymLinks-多视图