azure - URL Rewrite web.config 在域和页面之间添加假文件夹
问题描述
只是一个简单的问题。我有一个域website.com,这个页面有以国家代码命名的特定页面。
- website.com/英国
- website.com/ fr
- website.com/我们
- ...
我已经在我的 web.config 文件上创建了规则,并使用以下 URl 重写:
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url= "^([^/]+)/?$"/>
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="ContactUs.php?lang={R:1}" />
</rule>
页面是在 PHP 中生成的,名为lang的变量用于显示选择的页面并存在于 URL 中。
我想在我的域和页面之间添加“联系人/” 。
- website.com/联系方式/英国
- website.com/联系方式/fr
- ...
我有以下规则:
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="contact([^/]+)/?$"/>
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="ContactUs.php?lang={R:1}"/>
</rule>
哪位大神可以解释一下我有什么不明白的,谢谢
解决方案
您的正则表达式略有错误。
^contact\/([a-z]+)\/?$
假设您所有的国家/地区代码都只是字母,那应该可以满足您的需要。
推荐阅读
- c# - EWS 减少邮箱连接时间
- bash - 不知道如何运行 shell 脚本
- java - --Xmx 的 Java JVM 限制
- swift - SwiftUI 中的 ImagePicker
- php - 从一组数组中删除重复项
- java - 创建名为“entityManagerFactory”的bean时出错:[PersistenceUnit:默认]无法构建Hibernate SessionFactory
- javascript - js重新加载后如何从网络流中刮取m3u8(Python)
- javascript - React Native 上传图片失败
- python - 如何为没有概率的二元分类器(svm)绘制 ROC 并计算 AUC?
- r - 无法安装 tinytex 包。(也许应该更改存储库设置。)