在IIS中,RewriteBase不起作用。因此,下面的.htaccess规则已转换为IIS配置。但在IIS中,它给出了400个错误请求错误。我需要更正什么?
Htaccess规则
RewriteRule api/(.*)$ api.php?request=$1 [QSA,NC,L]IIS转换的规则
<rule name="Imported Rule 1" stopProcessing="true">
<match url="api/(.*)$"/>
<action type="Rewrite" url="api.php?request={R:1}" appendQueryString="true"/>
</rule> 发布于 2020-03-12 19:07:11
假设您的RewriteBase指令设置如下:
RewriteBase /subdir然后,您只需将此“前缀”附加到目标URL的开头(即.IIS指令中的RewriteRule替换或url属性值)。具体地说,它应该只作为相对替换字符串的前缀。
例如:
RewriteRule api/(.*)$ /subdir/api.php?request=$1 [QSA,NC,L]换句话说:
<action type="Rewrite" url="/subdir/api.php?request={R:1}" appendQueryString="true"/>如果设置了RewriteBase /,则只需使用一个斜杠作为前缀,例如。url="/api.php?request={R:1}"
这就是RewriteBase指令所做的全部工作。当在目录上下文中使用时,它为相对路径替换设置URL前缀。
https://stackoverflow.com/questions/60595421
复制相似问题