我在 .htaccess
文件中有以下重写配置,它在apache服务器中正常工作但在IIS服务器中无法正常工作 .
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^myservername/$ [NC]
RewriteRule ^(.*)$ http://myservername/$1 [R=301,L]
RewriteRule !\.(php|png|gif|jpg|css|htm|html|txt|js|swf|xml|ico|mp3|csv|wav|mid) /index.php [L,QSA]
如何在IIS上使用它?
2 回答
IIS不支持
.htaccess
开箱即用 . 要在IIS上使用Apache样式mod_rewrite规则,您需要第三方重写器,例如Iconics ISAPI Rewrite Filter或HeliconTech的ISAPI_Rewrite . 您'll probably need to tweak the rewrite rules because not all of mod_rewrite'的指令是受支持或适用的(因为Windows不是Unix) .如果您正在运行IIS7并且安装了UrlRewriter(这是免费的),您可以使用它,但您需要将重写规则转换为完全不同的格式 .
请创建名为web.config的新文件并粘贴以下内容