CMS 引擎的智能 URI 处理?

发布于 2024-09-01 22:14:59 字数 419 浏览 3 评论 0原文

我正在编写一个 CMS 引擎,该引擎改进了我网站上的博客引擎。到目前为止,现有博客只有一个智能 URI 处理程序 - 一个将 /123 转换为 /blog.php?p=123 的处理程序,目前由几个 完成>mod_rewrite 语句。当我的 CMS 中有更多“智能 URI”时,我担心这种方法会变得笨拙且笨拙。

目前,我已经考虑过一种可以在 PHP 中做到这一点的方法,但它在语义上似乎也是“邪恶的”。我会得到 ErrorDocument 404 以使用 PHP 脚本来解析 URI 并动态包含正确的脚本(途中将状态代码更改为 200)。

我应该这样做吗?还有更好的方法吗?我的目标是像 Launchpad.net 上那样进行简洁的智能 URI 解析。

I am writing a CMS engine that improves upon the blog engine on my website. So far, the existing blog only has one smart URI handler - one that converts /123 into /blog.php?p=123 and that's currently done by a few mod_rewrite statments. I am afraid that this method is unwieldy and kludgy for when I have more "smart URIs" in my CMS.

At the moment, I've thought about a way that could do this in PHP, but it also seems semantically "evil". I'd get the ErrorDocument 404 to use a PHP script that parses URIs and includes proper scripts dynamically (changing the statuscode to 200 on the way).

Should I do that? Are there better ways? I'm aiming for a neat smart URI parsing just like on Launchpad.net.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫瑾少女 2024-09-08 22:14:59

最常见的方法是通过mod_rewrite将所有内容重定向到index.php,并在php代码中完成所有url解析。例如,请参阅将所有内容重定向到index.php

The most common method is to redirect everything to index.php via mod_rewrite, and do all url parsing in php code. See for example Redirect everything to index.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文