【问题标题】:Expression Engine - Removing index.php completely表达式引擎 - 完全删除 index.php
【发布时间】:2012-06-23 23:09:18
【问题描述】:

一段时间以来,我一直在我的 .htaccess 文件中使用以下代码来使 EE URL 工作,而不需要 URL 中的 index.php。我发现虽然我从爬行工具中得到了一些报告,我得到了重复的内容,因为 /lorem/ipsum/ 也在某个地方弹出 /index.php/lorem/ipsum/。

我知道这可能是由于在 URL 中引用 index.php 的杂散链接造成的,但我想通过强制 index.php 退出链接来缩小差距。我环顾四周,但似乎找不到如何强制它。

RewriteEngine On
RewriteBase /

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

【问题讨论】:

    标签: .htaccess expressionengine


    【解决方案1】:

    当然。

    # Enable Rewrite Engine
    # ------------------------------
    RewriteEngine On
    RewriteBase /
    
    # Redirect index.php Requests
    # ------------------------------
    RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
    RewriteCond %{THE_REQUEST} ^GET
    RewriteRule ^index\.php(.+) $1 [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] 
    

    【讨论】:

    • 太棒了,感谢您花时间为我回答这个问题。完美运行!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-05
    • 2011-11-02
    • 1970-01-01
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多