【问题标题】:how to remove /index.php?/ while redirect 301 codeigniter pyrocms如何在重定向 301 codeigniter pyrocms 时删除 /index.php?/
【发布时间】:2015-12-02 18:23:32
【问题描述】:

在做一些任务时,我遇到了这个我无法解决的问题

该域在子域上是多语言的,例如此链接

http://ru.example.com

所以我需要把它改成目录:

http://example.com/ru

到目前为止,一切都还好,工作发现

当我尝试将旧链接重定向到新链接时 使用此 htaccess 代码

RewriteEngine on
RewriteCond %{HTTP_HOST} ^ru.example.com$
RewriteRule ^(.*)$ http://example.com/ru/$1 [L,NC,QSA]

所以结果是 example.com/ru/index.php?/about-us

这是错误的电话,我想帮助它成为

  example.com/ru/about-us

我正在使用基于 codigniter 的 Pyrocms

【问题讨论】:

标签: php .htaccess codeigniter redirect pyrocms


【解决方案1】:

终于解决了

在基于 Pyrocms Codeigniter 的 CMS 的主 Index.php 文件中

我的老板添加了此代码并解决了问题

if (strpos($_SERVER['SERVER_NAME'], 'ar.') !== false) {

$pageURL = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
    $pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= str_replace('ar.', '', $_SERVER["SERVER_NAME"]) . ":" . '/ar/' . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
} else {
    $pageURL .= str_replace('ar.', '', $_SERVER["SERVER_NAME"]) . '/ar/' . $_SERVER["REQUEST_URI"];
}

header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $pageURL);
die();
}

谢谢...

【讨论】:

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