mod_rewrite 重写 url

发布于 2024-09-16 12:17:35 字数 469 浏览 4 评论 0原文

嘿,有人可以伸出援手,让重写规则发挥作用吗?

我正在开发一个 CMS,目前的 URL 看起来像这样

page.php?id=2/About-us

我想删除

page.php?id=2/

URL 的一部分并仅显示

About-us

有什么想法如何使其工作吗?

编辑

我已经将我的URL更改为

page/PAGE_NAME

并使用了规则

RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]

但是,apache只是说在服务器上找不到index.php。

Hay, can someone lend a helping hand to get a rewrite rule to work?

I'm developing a CMS and the URL currently look like this

page.php?id=2/About-us

I want to remove the

page.php?id=2/

part of the URL and just show

About-us

Any ideas how to get this working?

EDIT

I have since changed my URLS to

page/PAGE_NAME

and used the rule

RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]

However, apache just says that index.php was not found on the server.

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

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

发布评论

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

评论(1

各自安好 2024-09-23 12:17:35

您确定它是 index.php 而不是 page.php 吗?

请尝试

RewriteRule ^/page/([^/]+)$ /index.php?page=$1 [L]

如果您需要永久搬家,

RewriteRule ^/page/([^/]+)$ /index.php?page=$1 [R=301,L]

Are you sure it is index.php and not page.php?

Please try

RewriteRule ^/page/([^/]+)$ /index.php?page=$1 [L]

If you need a permanent move

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