为什么这个 URL 重写不起作用?

发布于 2024-10-03 01:37:16 字数 493 浏览 0 评论 0 原文

这是“真正的”链接:

   domain.com/show_shop.php?id=4

这是重写的:

   domain.com/show_shop/4

我使用后者,因为我的 .htaccess 中有这个:

  RewriteRule ^show_shop/([0-9_]+)$ show_shop.php?id=$1 [NC]

但由于某种原因它不起作用。这个重写不会给出我想要的吗?

谢谢

编辑:

RewriteRule ^new_ad$ new_ad.php [NC] // WORKS FINE!
RewriteRule ^kategori/([0-9_]+)/([0-9]+)$ browse_cat.php?cat_gr=$1&p=$2 // WORKS FINE!

This is the "real" link:

   domain.com/show_shop.php?id=4

This is the rewritten:

   domain.com/show_shop/4

I use the later because I have this in my .htaccess:

  RewriteRule ^show_shop/([0-9_]+)$ show_shop.php?id=$1 [NC]

But it doesn't work for some reason. Will not this rewriterule give what I want?

Thanks

EDIT:

RewriteRule ^new_ad$ new_ad.php [NC] // WORKS FINE!
RewriteRule ^kategori/([0-9_]+)/([0-9]+)$ browse_cat.php?cat_gr=$1&p=$2 // WORKS FINE!

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

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

发布评论

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

评论(2

三生一梦 2024-10-10 01:37:17

尝试:

RewriteRule ^/show_shop/([0-9_]+)$ /show_shop.php?id=$1 [NC]

另外,如果可能的话,如果您在 VirtualHost 中打开这些功能,您可以看到所发生情况的日志:

 #warning, slows server perf
 RewriteLog "/var/log/apache/rewrite.log"
 RewriteLogLevel 9

Try:

RewriteRule ^/show_shop/([0-9_]+)$ /show_shop.php?id=$1 [NC]

Also, if possible, you can see the log of what's happening if you turn these on in your VirtualHost:

 #warning, slows server perf
 RewriteLog "/var/log/apache/rewrite.log"
 RewriteLogLevel 9
柒七 2024-10-10 01:37:16

如果调用了 show_shop 但未设置 URL 参数,则可能是由于 多视图。尝试禁用它。

If show_shop is called but the URL parameter is not set, it could be due to MultiViews. Try to disable it.

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