【发布时间】:2015-08-13 23:01:17
【问题描述】:
我以前的 Web 服务器运行 apache,并在每个站点的 .conf 文件中进行了重写。我什至不认为自己是一个中间重写用户,所以这可能并不理想。我正在尝试重现这个:
# except for requests for URL-path /abc/abc_system<whatever>
RewriteCond %{REQUEST_URI} !^(/abc/abc_system|/abc/themes|/abc/admin.php)
RewriteCond %{HTTP_HOST} ^([^.]+\.)*abctest\.example\.com [NC]
RewriteRule ^/abc/(.*)$ /abc/index.php/abc/$1 [L]
# one
RewriteRule ^/one/(.*)$ /one/index.php/one/$1 [L]
# two
RewriteRule ^/two/(.*)$ /two/index.php/two/$1 [L]
# three
RewriteRule ^/three/(.*)$ /three/index.php/three/$1 [L]
在 IIS 8 中使用 URL 重写。
<rewrite>
<rules>
<clear />
<rule name="abc ee" stopProcessing="false">
<match url="^abc/(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{URL}" pattern="^(/abc/abc_system|/abc/themes|/abc/admin.php)" ignoreCase="false" negate="true" />
<add input="{HTTP_HOST}" pattern="^([^.]+\.)*abctest\.example\.com" />
</conditions>
<action type="Rewrite" url="/abc/index.php/abc/{R:1}" logRewrittenUrl="true" />
</rule>
<rule name="abc one" stopProcessing="false">
<match url="^/one/(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="/one/index.php/one/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
第一个规则有效,但第二个规则(“abc one”)无效,所以我什至还没有为“二”和“三”添加规则。
网址基本上是这样的:
example.com/abc -> example.com/abc/index.php/abc(工作)
example.com/one -> example.com/one/index.php/one
example.com/two -> example.com/two/index.php/two
example.com/three -> example.com/three/index.php/three
第二条规则不起作用,我做错了什么? 一旦解决了这个问题,重复它是最好的方法还是有更有效的方法来浓缩它们?
非常感谢!
【问题讨论】:
标签: url-rewriting iis-8