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
.htaccess重定向自定义错误页并从url中删除index.php_Php_.htaccess - Fatal编程技术网

.htaccess重定向自定义错误页并从url中删除index.php

.htaccess重定向自定义错误页并从url中删除index.php,php,.htaccess,Php,.htaccess,我有以下代码从URL中删除index.php并重定向到自定义错误页面index.phpremove from URL工作正常,但我不知道如何重定向自定义错误页面代码 我试过这个代码,但不起作用 RewriteEngine on <br>RewriteCond %{REQUEST_FILENAME} !-f<br> RewriteCond %{REQUEST_FILENAME} !-d <br> RewriteRule ^(.*)$ index.php?/$0

我有以下代码从URL中删除index.php并重定向到自定义错误页面
index.php
remove from URL工作正常,但我不知道如何重定向自定义错误页面代码

我试过这个代码,但不起作用

RewriteEngine on
<br>RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d <br>
RewriteRule ^(.*)$ index.php?/$0 [QSA,L]<br>
重新编写引擎打开

重写cond%{REQUEST_FILENAME}-f
重写cond%{REQUEST_FILENAME}-d
重写规则^(.*)$index.php?/$0[QSA,L]
ErrorDocument 400/errors.php
ErrorDocument 403/errors.php
ErrorDocument 404/errors.php
ErrorDocument 405/errors.php
ErrorDocument 408/errors.php
ErrorDocument 500/errors.php
ErrorDocument 502/errors.php
ErrorDocument 504/errors.php


两者都有解决方案吗???

在config.php文件中做一些更改,转到“您的项目或域/application/config/config.php”

您将在下面的代码中找到

$config['index_page'] = 'index.php';
//Replace above code with below code
$config['index_page'] = '';
已经完成了,但如果仍然存在问题,则需要在config.php文件中再更改一个配置。 你需要找到下面的代码

$config['uri_protocol'] = 'AUTO'; 
//Replace above code with below code
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
注意:.htaccess代码因主机服务器而异。在某些托管服务器(例如:Godaddy)中,是否需要使用额外的?在上面代码的最后一行。在适用情况下,以下行将替换为最后一行:

// Replace last .htaccess line with this line
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 

我的配置文件已经有了上面提到的相同代码。