.htaccess - IIS 上的 rewritebase 的替代方案是什么?

标签 .htaccess iis mod-rewrite

我的网站中有以下 .htaccess 文件 - 我必须将其重新定位到 Windows IIS 计算机,并且在使用 URL 重写模块导入规则和创建规则时遇到问题web.config 文件。

这是我的.htaccess 文件

# Rewrite URLs and direct to index.php

<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
##
## If moving host, change the structure below to folder name of where public folder lives
##
RewriteBase /foldername/public
##
##
##
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

它在 RewriteBase 上失败,但我知道 .htaccess 文件中的这一点对于我的网站正常运行至关重要。

谁能给我指点一下吗?

最佳答案

它将转换为以下网址重写规则:

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.+)$" ignoreCase="false" />
      <conditions>
        <!--##-->
        <!--## If moving host, change the structure below to folder name of where public folder lives-->
        <!--##-->
        <!--##-->
        <!--##-->
        <!--##-->
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
      </conditions>
      <action type="Rewrite" url="/foldername/public/index.php?url={R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

关于.htaccess - IIS 上的 rewritebase 的替代方案是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60253042/

相关文章:

php - .htaccess 不适用于 Apache2

php - 添加/索引/链接之间的奇怪分页问题 - 表达式引擎

c# - 如何确定 "IIsWebDirectory"或 "IIsWebVirtualDir"是ASP.NET应用程序?

c# - UseIISPlatformHandler() 是否正确弃用为 UseIIS()?

azure - Web Api 上传到 Azure 存储 - 请求实体太大

php - 站点安全正则表达式处理程序? (PHP)

apache - "site down"页的重写规则

.htaccess - 通过 htaccess 访问特定域时强制用户访问单个站点

php - codeigniter:使用 htaccess 保护 Controller

apache - 将 http 重定向到 https 排除特定 IP