很好的 url 与 apache 和 php

发布于 2024-09-06 13:10:09 字数 57 浏览 1 评论 0原文

我有类似 /story.php?id=31
的网址 我想将其显示为 /31.html 如何?

I have urls like /story.php?id=31
I want to show it as /31.html
How?

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

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

发布评论

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

评论(3

2024-09-13 13:10:09

mod_rewrite 就是答案。请参阅本指南这个


/31.html -> /story.php?id=31 (呈现链接是另一个更简单的问题)

RewriteEngine on
RewriteRule   ^/([0-9]+)\.html$ /story.php?id=$1 [L,QSA]

mod_rewrite is the answer. See e.g. this guide or this one.


/31.html -> /story.php?id=31 (rendering your links is another - and easier - issue)

RewriteEngine on
RewriteRule   ^/([0-9]+)\.html$ /story.php?id=$1 [L,QSA]
凑诗 2024-09-13 13:10:09

您需要使用 Apache 的 mod_rewrite 引擎。

您正在寻找的规则看起来像这样:

RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)\.html$ story.php?id=$1 [L]

You'll want to use Apache's mod_rewrite engine.

The rule you are looking for would look something like this:

RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)\.html$ story.php?id=$1 [L]
堇色安年 2024-09-13 13:10:09

使用 apache 和 mod_rewrite,可能的解决方案是:

RewriteEngine On
RewriteRule ^([0-9]+)\.html /story.php?id=$1 [NC,QSA,L]

Using apache and mod_rewrite, a possible sollution could be:

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