我正在使用获取简单的cms在我的国际空间站服务器(实际上必须使用国际空间站),并有一个插件,以启用重写国际空间站与web.config。
web.config来源:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="GetSimple Fancy URLs" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="?id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>但是我在主文件夹/和子文件夹/en上的内容管理系统,例如:
http://domainname.com/ (main cms) http://domainname.com/en/ (子文件夹中的另一个cms )
使用上面的web.config,主cms工作成功,但子文件夹上的cms不工作(与以前一样给出404 )
如何将子文件夹规则实施到web.config file?所以2个cms成功地工作了。
我试图将相同的web.config文件放在子文件夹(/en)下,但不起作用。
非常感谢,
发布于 2012-11-16 20:14:43
首先,你的正则表达式只会匹配网站根目录下的URL,例如domain.com/page或domain.com/anotherpage。它不会匹配像domain.com/subdir/page这样的子目录。但这可能就是你想要的,我不知道。
要使其也适用于/en,请将规则更改为:
<rule name="GetSimple Fancy URLs" stopProcessing="true">
<match url="^(en/)?([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}?id={R:2}" />
</rule>如果您想要一个适用于任何两个字符的语言代码的更通用的解决方案,请使用以下代码:
<rule name="GetSimple Fancy URLs" stopProcessing="true">
<match url="^([a-z]{2}/)?([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}?id={R:2}" />
</rule>它应该就在根目录下的web.config中。
https://stackoverflow.com/questions/13396309
复制相似问题