expressionengine URL重写2.3.1
在 EE 2.2.2 中,我的 htaccess 文件中包含此内容
RewriteRule ^(.*)$ /index.php/view/$1 [L]
允许我将 domain.com/index.php/view/phone 重写为 domain.com/phone。
在 EE 2.3.1 中,这不再有效。问题似乎出在 system\codeigniter\system\core\URI.php 上,我发现这个文件没有什么变化。如果我将 URI.php 替换为 2.2.2 版本,那么它会再次工作。我的问题是发生了什么变化以及如何让它再次发挥作用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新的答案
经过一段时间的思考(和测试),我想出了一个替代解决方案,它可能适合您更新的 EE 的需求。
假设您的重写规则如下:
现在,我的建议是让您的
view
模板组成为索引模板组。在
view
模板组中的索引模板中,您可以具有以下内容:这允许您在不添加其他重写规则的情况下,让访问者转到 http://example.org/phone 并且 view/index 模板将尝试查找条目 ID 标记为“phone”的条目。如果找不到该条目(
{if no_results}
部分),请嵌入另一个模板。在这种情况下,我假设您想显示某种首页。这还允许您在
view
模板组下创建普通模板,例如view/create_entry
,当您转到 http://example.org/create_entry这应该可以工作 - 并且可以轻松定制以满足您的需求。
Updated answer
After some time with thoughts (and testing) I've come up with an alternate solution, that might fit your need with the updated EE.
Assuming your rewrite rules are like the following:
Now, my suggestion is to let your
view
template group be the index template group.In your index template in the
view
template group, you could have the following:This allows you to, without adding other rewrite rules, have your visitors go to http://example.org/phone and the view/index template will try to find the entry with the entry ID labeled 'phone'. If that entry cannot be found (the
{if no_results}
part) embed another template. In this case I would assume you'd like to show some sort of frontpage.This also allows you to, under the
view
template group, create ordinary templates likeview/create_entry
which will show up, when you go to http://example.org/create_entryThis should work - and is easy customizable to fit your needs.