重写规则代码不适用于深页

发布于 2025-01-28 18:24:08 字数 497 浏览 2 评论 0原文

我编写一些重写规则,以操纵域地址之后的第一个文件夹,作为指示语言的查询字符串。

<rule name="en">
<match url="^en/(.*?/)" />
<action type="Rewrite" url="./{R:1}/?lang=en" />
</rule>

上面的代码适用于第一步文件夹:

http://example.com/en/members 
Executes: 
http://example.com/members/?lang=en 

但不可行或更深入的步骤。

http://example.com/en/members/profile/ 
Executes: 
http://example.com/members/?lang=en 

第二步文件夹(配置文件)被忽略。

I write some rewrite rule to manipulate the first folder after domain address as a query string indicating the language.

<rule name="en">
<match url="^en/(.*?/)" />
<action type="Rewrite" url="./{R:1}/?lang=en" />
</rule>

The code above works for first step folders:

http://example.com/en/members 
Executes: 
http://example.com/members/?lang=en 

but not or second and deeper steps.

http://example.com/en/members/profile/ 
Executes: 
http://example.com/members/?lang=en 

and the second step folder (profile) is being ignored.

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

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

发布评论

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

评论(1

与君绝 2025-02-04 18:24:08

您的第一个规则也不起作用,因为参数^en/(.*。

<rule name="en">
  <match url="^en/([^/]+)" />     
  <action type="Rewrite" url="http://example.com/{R:1}/?lang=en" />
</rule>

”在此处输入图像说明”

Your first rule shouldn't work either, because the parameter ^en/(.*?/) doesn't match en/members, but you can try this rule:

<rule name="en">
  <match url="^en/([^/]+)" />     
  <action type="Rewrite" url="http://example.com/{R:1}/?lang=en" />
</rule>

enter image description here

enter image description here

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