My .htaccess file doesn't work on IIS
I have the following rewrite configuration in my .htaccess
file which is working fine in apache server but its not working properly in IIS server.
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^myservername/$ [NC] RewriteRule ^(.*)$ http://myservername/$1 [R=301,L] RewriteRule !\.(php|png|gif|jpg|css|htm|html|tx开发者_如何学运维t|js|swf|xml|ico|mp3|csv|wav|mid) /index.php [L,QSA]
How do I get this working on IIS?
IIS doesn't support .htaccess
out of the box. To use Apache style mod_rewrite rules on IIS you'll need a third party rewriter such as Iconics ISAPI Rewrite Filter or HeliconTech's ISAPI_Rewrite. You'll probably need to tweak the rewrite rules because not all of mod_rewrite's directives are supported or applicable (because Windows is not Unix).
If you're running IIS7 and it has UrlRewriter installed (which is free) you could use that but you'd need to convert your rewrite rules to a completely different format.
please create new file with name web.config and paste the following
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" />
</conditions>
<action type="None" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^(.*)$" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
精彩评论