如何删除index.php?从其他网站重定向时?

时间:2019-07-16 07:49:43

标签: codeigniter redirect

我有2个域 示例:example.com和result.com都基于codeigniter构建。  我想将example.com的所有URL重定向到result.com,所以我将所有URL从example.com的面板重定向到result.com。

因此,当我将exapmle.com/folder/xyz的网址重定向到result.com后,它显示:-https://result.com/index.php?folder/xyz

是否有删除index.php的内容? ?

1 个答案:

答案 0 :(得分:0)

尝试以下

打开config.php并进行以下替换

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

$config['index_page'] = ""

在某些情况下,uri_protocol的默认设置无法正常工作。只需替换

$config['uri_protocol'] ="AUTO"

作者

$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)中,是否需要额外使用?在上述代码的最后一行。在适用的情况下,以下行将替换为最后一行: