简体   繁体   English

IIS7 URL仅重写根文件

[英]IIS7 URL Rewrite root files only

This question was asked 4 years ago yet no answers on them. 这个问题是在4年前提出的,至今还没有答案。

The situation is, to rewrite root/xyz to root/index.php?code=xyz without affecting any other files and subdirectories. 情况是,将root / xyz重写为root / index.php?code = xyz,而不会影响任何其他文件和子目录。

I have already did this rewrite using the following 我已经使用以下内容进行了重写

<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<rewrite>
<rules>

<rule name="Rewrite User Links to Get">
<match url="^([_0-9a-z-]+)" /> 
<action type="Rewrite" url="?code={ToLower:{R:1}}" />
</rule> 

</rules>
</rewrite>
</system.webServer>
</location>

But with this code, other files in the root and sub directories ceases to function. 但是使用此代码,根目录和子目录中的其他文件将停止运行。 What match string or expression should I use to avoid this? 我应该使用什么匹配的字符串或表达式来避免这种情况?

Found the answer to this question here IIS 7.0 URL Rewrite Module - Root URL doesn't display 在这里找到了这个问题的答案IIS 7.0 URL重写模块-根URL不显示

<match url="^(?:([^/.]+))?$" /> 

This fixed the problem. 这解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM