URL 的条件 .htaccess

发布于 2024-09-28 15:31:54 字数 345 浏览 1 评论 0原文

RewriteRule ^photographs/?$ photographs.php [L]
RewriteRule ^photographs/(.*)/?$ photographs.php?cat=$1 [L,QSA]
RewriteRule ^photographs/(.*)/(.*)/?$  photographs.php?cat=$1&page=$2 [L,QSA]

我需要这个有

  • /photographs
  • /photographs/category
  • /photographs/category/3

等选项

RewriteRule ^photographs/?$ photographs.php [L]
RewriteRule ^photographs/(.*)/?$ photographs.php?cat=$1 [L,QSA]
RewriteRule ^photographs/(.*)/(.*)/?$  photographs.php?cat=$1&page=$2 [L,QSA]

I need this to have options such as

  • /photographs
  • /photographs/category
  • /photographs/category/3

Thanks

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

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

发布评论

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

评论(1

与他有关 2024-10-05 15:31:54
RewriteRule ^photographs/?$ index.php [L]
RewriteRule ^photographs/([^/]+)/?$ index.php?cat=$1 [L,QSA]
RewriteRule ^photographs/([^/]+)/([^/]+)/?$  index.php?cat=$1&page=$2 [L,QSA]

这是因为 (.*) 也匹配 / 字符。

RewriteRule ^photographs/?$ index.php [L]
RewriteRule ^photographs/([^/]+)/?$ index.php?cat=$1 [L,QSA]
RewriteRule ^photographs/([^/]+)/([^/]+)/?$  index.php?cat=$1&page=$2 [L,QSA]

That's because (.*) also matches / character.

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