.htaccess 修复了 PHP 中漂亮的永久链接?

发布于 2024-09-12 05:09:11 字数 486 浏览 1 评论 0原文

也许我的处理方式是错误的,但我在我们自己开发的 CMS 中有一些页面,我想使用漂亮的永久链接进行转换。目前,他们的页面 URL 如下所示:

http://ourdomain.com/articles/ ?permalink=blah-blah-blah

我想将它们转换为:

http:// /ourdomain.com/articles/blah-blah-blah

我在数据库中有一个用于永久链接的列,当创建文章时,会自动将标题转换为永久链接。

我将如何编写重写规则来完成此任务?这是实现这一目标的最佳方法吗?

Maybe I'm going about this in the wrong way, but I have some pages in our homegrown CMS that I want to convert to using pretty permalinks. Currently, their page URLs look this this:

http://ourdomain.com/articles/?permalink=blah-blah-blah

I want to convert these to:

http://ourdomain.com/articles/blah-blah-blah

I have a column in the db for permalinks, that when the article is created, automatically converts the title to a permalink.

How would I write the rewrite rule to accomplish this? Is this even the best way to accomplish this?

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

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

发布评论

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

评论(1

夏了南城 2024-09-19 05:09:11

如果查询字符串中没有任何内容,您可以省略 QSA

RewriteRule articles/(.+) articles/?permalink=$1 [QSA,L,B]

If there's nothing in the query string you can omit QSA:

RewriteRule articles/(.+) articles/?permalink=$1 [QSA,L,B]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文