我如何 remove/fix Expressionengine 在与索引页面无关的模板组的 url 中添加 "index.php"

How do I remove/fix that Expressionengine adds "index.php" in urls of template groups that has nothing to do with the index page

我在使用表达式引擎时遇到了一个奇怪的问题。我有一个网站主页,我为它创建了一个名为“索引”的模板组。在索引模板组中,索引页面模板按预期工作,www.domainname.com/ 转到 index.php 页面。 我遇到的问题是,如果我添加其他模板组,那些 url 将如下所示:

www.domainname.com/index.php/template_group_name/template_file

我不确定我做错了什么,因为在他们的文档中 url 应该是这样的: www.domainname.com/template_group_name/template_file

如何从域中删除 index.php?

您需要使用 public_html.

根目录中的 .htaccess 文件修复此问题
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond  !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]

找到了,它隐藏在他们的手册中的某个地方,其他人有同样的问题,将以下内容粘贴到 .htaccess 文件中:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) / [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/ [L]
</IfModule>

来源: https://docs.expressionengine.com/latest/installation/best-practices.html#removing-indexphp-from-your-urls