Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
删除codeigniter中的index.php(在本地可以正常工作,但在生产环境中不起作用)_Php_.htaccess_Codeigniter 2_Codeigniter Routing - Fatal编程技术网

删除codeigniter中的index.php(在本地可以正常工作,但在生产环境中不起作用)

删除codeigniter中的index.php(在本地可以正常工作,但在生产环境中不起作用),php,.htaccess,codeigniter-2,codeigniter-routing,Php,.htaccess,Codeigniter 2,Codeigniter Routing,我花了很多时间寻找答案,但没有发现任何人有相同的问题:) 我的本地版本很好(在AMPP上运行),没有index.php的URL工作得很好。 “我的本地文件夹”和“产品文件夹”都位于子文件夹中,因此如下所示: http://localhost/ci/ http://website.com/cms_ci/ 但是当我把我的文件夹放在prod服务器上时,主页是正常的,但是如果我想访问,我会得到一个404。 如果我继续下去,它就起作用了 以下是my config和htaccess文件的设置: confi

我花了很多时间寻找答案,但没有发现任何人有相同的问题:)

我的本地版本很好(在AMPP上运行),没有index.php的URL工作得很好。 “我的本地文件夹”和“产品文件夹”都位于子文件夹中,因此如下所示:

http://localhost/ci/
http://website.com/cms_ci/
但是当我把我的文件夹放在prod服务器上时,主页是正常的,但是如果我想访问,我会得到一个404。 如果我继续下去,它就起作用了

以下是my config和htaccess文件的设置:

config.php

$config['base_url'] = 'http://localhost:8080/cms/'; 
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
HTACCESS

Options -Indexes
   RewriteEngine on
   RewriteCond $1 !^(index\.php|assets/|robots\.txt)
   RewriteRule ^(.*)$ index.php/$1 [L]
当然,在我的prod-config文件中,我已经更改了

$config['base_url'] = 'http://localhost:8080/cms/'; 

我尝试了各种htaccess文件,但现在我有点结巴了

提前感谢

尝试此htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

重新启动发动机
重写基/
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php?/$1[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
ErrorDocument 404/index.php
您可以试试这个-

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|public|img|images|js|fonts|assets|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
1美元^(索引\.php | public | img | images | js | font | assets | robots\.txt | css)
重写规则^(.*)$index.php/$1[L]

这应该管用

检查您的服务器配置上是否允许htaccess。当我执行phpinfo()时,您可以在“加载的模块”中查看@mod_rewrite的一些链接;。但是当我在htaccess中插入垃圾代码时,我没有500个错误…检查您的htaccess文件的权限,这是什么意思?您好,我试过了,但没有任何改变。当我使用website.com/index.php/controller/时,我仍然可以访问主页和其他页面。当我尝试website.com/controller/try with:website.com/index.php?/controller/无论我在index.php后面放了什么url,我仍然是404?(webiste.com/index.php?/controller/)我要去主页。
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|public|img|images|js|fonts|assets|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>