MediaTemple 上的表达式引擎 - 删除索引.php会导致"no input file specified"



我有一个带有标准表达式htaccess代码的MT网站,以删除index.php和主页可行,如果我将index.php放在URL中,则所有其他页面都可以使用。没有它,我会得到"未指定的输出文件"。它可以在我的本地和非MT服务器上使用,因此我知道它是一种环境。需要更改HTACCESS中的内容才能使其在MT上工作?

<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /

# Use Dynamic robots.txt file
# ------------------------------
RewriteRule robots.txt /robots.php [L]

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index.php [NC]
RewriteCond %{THE_REQUEST} !/admin/.*
RewriteRule (.*?)index.php/*(.*) /$1$2 [R=301,L]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

感谢@danielcgold通过Twitter的答案:

尝试使用此行RewriteRule ^(.*)$ /index.php?/$1 [L]并注意?index.php

之后

我昨晚在(MT)上为我所有表达式网站的标准重写规则发布了要点。

## BEGIN Expression Engine Rewrite
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
## END Expression Engine Rewrite

使用EE 2.7.0和Mediatemple的网格服务(以前是" GS"),我很幸运使用标准.htaccess:

<IfModule mod_rewrite.c>
        RewriteEngine On
        # Removes index.php from ExpressionEngine URLs
        RewriteCond $1 !.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

,然后进入AccountCenter> [mydomain.com]> PHP设置,然后将PHP版本从 5.5.5.1 CGI(最新)转换为 5.3.7 CGI(stable)

我在表达式堆栈交换网站上发布了该解决方案,但是简而言之,我们必须使用的共享托管环境被迫使用FastCGI,我们无法修改任何CGI或PHP配置。

试图自己创建$_SERVER['PATH_INFO']变量,对我有用的是3个步骤"自定义"方法:

  1. 首先,在ExpressionEngine > CP Home > Admin > System Administration > Output And Debugging中,我设置强制URL查询字符串 to no
  2. 接下来,如先前的答案中所述,我将.htaccess指令从RewriteRule ^(.*)$ /index.php/$1 [L,QSA] 更改为 RewriteRule ^(.*)$ /index.php?/$1 [L,QSA](extra in index.php)。
  3. 最后,我将此自定义的PHP代码添加到站点root的index.php文件的顶部,以"强制" $_SERVER['PATH_INFO']变量到准确的存在中:

    <?php
        $path = $_SERVER['REQUEST_URI'];
        $pos = strpos($path, '?');
        if ($pos !== false)
            $path = substr($path, 0, $pos);
        $_SERVER['PATH_INFO'] = $path;
        /**
         * ExpressionEngine - by EllisLab
           ...
           ...
    

我希望这对某人有帮助!我真的拔了头发,试图找到更优雅的解决方案!

最新更新