我在IIS mod_rewrite模块中导入.htaccess文件时遇到问题。 出现3个错误。
.htaccess`
Options +FollowSymLinks -Indexes -MultiViews AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
##If your NeoFrag directory is not at http root
##you need to replace "/" by the correct directory, for example "RewriteBase /neofrag/"
RewriteBase /
##Allow direct access to specific directories
#RewriteCond %{REQUEST_URI} ^/(dir1|dir2)/
#RewriteRule .* - [L,QSA]
RewriteCond %{REQUEST_URI} !^/backups/
##Allow direct access to specific files
#RewriteCond %{REQUEST_FILENAME} /file1\.php [OR]
#RewriteCond %{REQUEST_FILENAME} /file2\.php [OR]
RewriteCond %{REQUEST_FILENAME} \.(png|jpg|jpeg|gif|swf|eot|svg|ttf|woff|woff2|zip)$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L,QSA]
RewriteCond %{REQUEST_URI} \.html
RewriteRule (.*)\.html(.*) $1$2 [R=301,L]
RewriteRule .* index.php [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
</IfModule>
XML视图
<rewrite>
<!--This directive was not converted because it is not supported by IIS: RewriteBase /.-->
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url=".*" ignoreCase="false" />
<conditions>
<add input="{URL}" pattern="^/(dir1|dir2)/" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<!--This rule was not converted because only some of the conditions are using the OR flag.-->
<rule name="Imported Rule 3" stopProcessing="true">
<match url="(.*)\.html(.*)" ignoreCase="false" />
<conditions>
<add input="{URL}" pattern="\.html" ignoreCase="false" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}{R:2}" />
</rule>
<!--The rule cannot be converted into an equivalent IIS format because of unsupported flags: E-->
有些人可以帮我解决这3行错误吗?
RewriteBase /
RewriteRule .* - [L,QSA]
RewriteRule .* index.php [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
答案 0 :(得分:0)
RewriteBase /
您可以删除此行,并在RewriteRule
替换上包含斜杠前缀。即。更改以下行:
RewriteRule (.*)\.html(.*) $1$2 [R=301,L] RewriteRule .* index.php [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
到
RewriteRule (.*)\.html(.*) /$1$2 [R=301,L]
RewriteRule .* /index.php [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
此规则未转换,因为只有部分条件使用OR标志
转换器似乎试图转换注释掉的代码??删除所有以#
开头的行。
RewriteRule .* /index.php [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
E
标志设置环境变量。我不会说IIS,但您可以删除上述指令中的E=REMOTE_USER:%{HTTP:Authorization},
部分,而是使用mod_setenvif(这会转换吗?)。例如,E
标志等同于以下内容:
SetEnvIf Authorization "(.*)" REMOTE_USER=$1