【问题标题】:Removing index.php from some ExpressionEngine 2 paths从一些 ExpressionEngine 2 路径中删除 index.php
【发布时间】:2012-08-09 02:57:51
【问题描述】:

我根据User Guide instructions 使用干净的网址设置了 ExpressionEngine 2.4。他们工作得很好。但是当我使用来自channel entries tag 的路径单个变量时,我仍然在路径中得到“index.php”。例如:

{exp:channel:entries channel="news"}
  ..
  <a href="{comment_url_title_auto_path}">Test</a>
{/exp:channel:entries}

呈现给:

<a href="http://eetest/index.php/mothra-is-attacking">Test</a>

我目前有一个由两部分组成的解决方法:

首先,我使用 Find and Replace Plus 插件从 url 中清除“index.php”:

{exp:channel:entries channel="news" limit="1"} 
    <a href="{exp:replace_plus find="index.php/"}
             {comment_url_title_auto_path}
           {/exp:replace_plus}">Test</a>
{/exp:channel:entries}

这给了我工作干净的网址:

<a href="http://eetest/mothra-is-attacking">Test</a>

其次,如果我错过了模板中的网址,我会确保将任何包含“index.php”的网址重定向到没有的网址。在我的 .htaccess 中,我使用了这个子句:

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

因此,尽管此设置有效,但它很杂乱(让我在模板中的链接上撒上查找/替换)并且效率有点低(在某些情况下强制重定向),而且它不是完全 SEO 友好的(对于那些使用索引呈现的 url .php)。

我的问题是,我是否缺少一些设置来防止 index.php 首先出现在其中一些路径中?

以下是我的 config.php 中的一些相关设置:

$config['index_page'] = ''; //per the user docs on removing index.php
$config['uri_protocol'] = 'AUTO'; //didn't have luck with the other values
$config['base_url'] = '';
$config['url_suffix'] = '';

【问题讨论】:

    标签: .htaccess expressionengine


    【解决方案1】:

    找到了。

    我必须转到管理->频道管理->频道,然后为我的每个频道点击“编辑首选项”。

    在那里,我从“路径设置”部分的“频道 URL”字段中删除了“index.php”。

    点击更新并刷新我的前端页面后。上面显示的路径中的所有 index.php 都消失了。不再需要解决方法!

    【讨论】:

      【解决方案2】:

      解决此问题的另一种方法是使用 Deploy Helper 或 Relocate - 这两个出色的附加组件可将通常分布在整个控制面板中的所有路径变量拉到一个位置,以便您可以快速轻松地找到它们并将其替换为单击一个按钮。这样一来,任何会影响您的自动路径的杂散 index.php 引用都将被找到并更新。两个很棒的工具。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-28
        • 2012-06-11
        • 1970-01-01
        • 2010-11-29
        • 2016-08-30
        • 2014-07-19
        • 2018-04-27
        相关资源
        最近更新 更多