【问题标题】:php URL rewrite works on apache, not 100% on a litespeed serverphp URL 重写适用于 apache,而不是 100% 在 litespeed 服务器上
【发布时间】:2016-12-10 11:26:55
【问题描述】:

我在让 PHP 脚本在新服务器上运行时遇到了一些问题 - 我已经从 apache 转到了 Litespeed 服务器,但我无法让小型 CMS 运行它。

简而言之,.htaccess 包含:

 ServerName www.domain.co.uk
ServerAlias domain.co.uk
DocumentRoot /home/domain/public_html/
<Directory  /home/ttedomainpublic_html/>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.co.uk [NC]
            RewriteRule ^(.*)$ index.php [L]
    RewriteRule ^(.*) http://www.domain.co.uk/$1 [L,R=301]
    RewriteBase /
    RewriteRule ^(admin|content|css|images|img|non_public|pdf|renderers|scripts|sendmail|templates) - [L]
</Directory>

并且 index.php 包含:

<?php
include("non_public/config.php");

// Get the request URI
$requestUri = $_SERVER['REQUEST_URI'];
$requestUri = preg_replace("~^/~","",$requestUri);
$requestUri = str_replace("/","_",$requestUri);


// Make sure that we'll get the index
if(empty($requestUri)) $requestUri = "index";

if(file_exists(ROOT_PATH . "content/" . $requestUri))
{
// Include the header
include(ROOT_PATH . "templates/header.php");

// Check if there's a renderer
if(file_exists(ROOT_PATH . "renderers/" . $requestUri . ".php"))
{
    include(ROOT_PATH . "renderers/" . $requestUri . ".php");
}
else
    echo file_get_contents(ROOT_PATH . "content/" . $requestUri);

// Include the footer
include(ROOT_PATH . "templates/footer.php");
}

else
    echo file_get_contents(ROOT_PATH . "content/404");
?>

所以上面应该从 content/ 中保存的内容文件、模板中的一些点点滴滴和 renderers/ 中的一些基本内容组合在一起目录。

我希望到目前为止还有意义吗?几年来,这在 Apache 服务器上运行良好,但在 Litespeed 下无法运行。 当前访问 www.domain.co.uk/notes 时的最终结果只是一个 404 页面,因为显然 www.domain.co.uk/notes/index.php 等不存在,服务器似乎无法将页面放在一起。

谁能指点我正确的方向?

非常感谢...

【问题讨论】:

  • 哇,零响应! :( 我猜 litespeed 服务器不太受欢迎......

标签: php .htaccess mod-rewrite url-rewriting litespeed


【解决方案1】:

尝试启用重写日志记录并访问该页面。重写日志应该解释重写规则中发生的事情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-02
    • 2011-12-19
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多