.htaccess PHP 进度

发布于 2024-09-24 16:11:36 字数 390 浏览 0 评论 0原文

感谢到目前为止为我提供帮助的人们,我想我已经准备好迈出最后一步了。

我的网址看起来像这样。

/brochure.php?cat_path=35&name=concrete-intermediate-posts

这太棒了,最后我只需要知道如何将该 URL 转换为所需的 URL:

/brochure/35/concrete-intermediate-posts

就像 Stack Overflow 格式一样。

谁能帮我制定正确的 .htaccess 规则吗?

另外,如果我在其他部分有其他 get 变量,这种重写会损害它们吗? (他们使用不同的变量名称)

谢谢

Thanks to the people that've helped me so far with this, I'm ready for the last step, I think.

I've got my URLs looking like this.

/brochure.php?cat_path=35&name=concrete-intermediate-posts

This is great and finally I just need to know how to turn that URL into this desired URL:

/brochure/35/concrete-intermediate-posts

Just like the Stack Overflow format.

Could anyone help me with the correct .htaccess rule?

Also, if I have other get variables in other sections, will this re-write harm them? (they use different variable names)

Thanks

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

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

发布评论

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

评论(2

丑丑阿 2024-10-01 16:11:36

使用mod_rewrite,您宁愿做相反的事情:将 /brochure/35/concrete-intermediate-posts 内部重写为 /brochure.php?cat_path=35&name=concrete-intermediate -posts

RewriteRule ^([^/]+)/(\d+)/([^/]+)$ $1.php?cat_path=$2&name=$3 [L,QSA]

另一边,使用类似 /brochure/35/concrete-intermediate-posts 的 URL 路径,而不是 /brochure.php?cat_path=35&name=concrete HTML 文档中的 -intermediate-posts 将使用 PHP 完成。

With mod_rewrite you will rather do the opposite: rewrite a URL path like /brochure/35/concrete-intermediate-posts internally to /brochure.php?cat_path=35&name=concrete-intermediate-posts:

RewriteRule ^([^/]+)/(\d+)/([^/]+)$ $1.php?cat_path=$2&name=$3 [L,QSA]

The other side, using a URL path like /brochure/35/concrete-intermediate-posts instead of /brochure.php?cat_path=35&name=concrete-intermediate-posts in the HTML documents, would be done with PHP.

素染倾城色 2024-10-01 16:11:36

我希望你的意思是这样的:

RewriteEngine On
RewriteBase /
RewriteRule ^brochure/([0-9]+)/([-a-zA-Z0-9]+)$ /brochure.php?cat_path=$1&name=$2 [L]

I Hope you mean something like this:

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