【问题标题】:how can i remove index.php? while redirecting from other site?如何删除 index.php?从其他站点重定向时?
【发布时间】:2019-07-16 07:49:43
【问题描述】:

我有 2 个域 示例:- example.com 和 result.com 都建立在 codeigniter 之上。 我想将 example.com 的所有 url 重定向到 result.com,所以我将 example.com 的 cpanel 的所有 url 重定向到 result.com。

所以,当我在重定向到 result.com 之后放置 exapmle.com/folder/xyz 的 URL 时,它显示:- https://result.com/index.php?folder/xyz

有没有办法删除 index.php? ?

【问题讨论】:

标签: codeigniter redirect


【解决方案1】:

试试下面的

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

【讨论】:

    猜你喜欢
    • 2016-07-02
    • 1970-01-01
    • 2020-05-26
    • 2019-11-23
    • 2018-03-31
    • 1970-01-01
    • 2013-09-02
    • 2019-12-11
    • 2012-04-03
    相关资源
    最近更新 更多