【发布时间】: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