.htaccess 中的简单 RewriteRule

发布于 2024-09-09 23:13:49 字数 1004 浏览 2 评论 0原文

好吧,听起来简单,看起来简单,重量也简单。但事实并非如此。 我这辈子都无法让这个工作正常进行。

假设我有这样的 URL 结构:

http://www.test.com/%动作%[/%param1%/%paramX%]

我需要重定向(实际上我想要重写)到:

http ://www.test.com/index.php?option=com_%action%&param=[%param1%,%paramX%]

例如:

http://www.test.com/product/25 /所有产品/食品/蛋糕/芝士蛋糕

变成:

http://www .test.com/index.php?option=com_product&param=25,allproducts,食物,蛋糕,芝士蛋糕

想法吗? :-)

OK, it sounds simple, it looks simple and it weighs simple. But it's not.
I can't for the life of me get this working.

Let's say I have this URL structure:

http://www.test.com/%action%[/%param1%/%paramX%]

I need to redirect (actually I want a REWRITE) to:

http://www.test.com/index.php?option=com_%action%¶m=[%param1%,%paramX%]

For example:

http://www.test.com/product/25/allproducts/food/cakes/cheesecake

Becomes:

http://www.test.com/index.php?option=com_product¶m=25,allproducts,food,cakes,cheesecake

Ideas? :-)

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

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

发布评论

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

评论(1

淑女气质 2024-09-16 23:13:49

如果你不介意有这种参数:

http://www.test.com/index.php?option=com_product¶m=25/allproducts/food/cakes/cheesecake

你可以尝试这个规则:

RewriteRule ^([^/]*)/(.*) /index.php?option=com_$1¶m=$2

它应该有效,但我还没有检查它;)

if you dont mind to have this kind of parameters:

http://www.test.com/index.php?option=com_product¶m=25/allproducts/food/cakes/cheesecake

you can try this rule:

RewriteRule ^([^/]*)/(.*) /index.php?option=com_$1¶m=$2

it should work, but i havent check it ;)

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