删除IIS7上带有web.config的.php扩展
我有一个.htaccess文件,该文件从文件中删除.php扩展名,例如将so.com/question.php转换为so.com/question,并重定向文件夹中的索引文件,例如,so.com/answer/index.php重定向到so.com/answer/,完全如前所述删除IIS7上带有web.config的.php扩展,php,.htaccess,url-rewriting,web-config,Php,.htaccess,Url Rewriting,Web Config,我有一个.htaccess文件,该文件从文件中删除.php扩展名,例如将so.com/question.php转换为so.com/question,并重定向文件夹中的索引文件,例如,so.com/answer/index.php重定向到so.com/answer/,完全如前所述 我刚刚在IIS7上本地设置了我的站点,需要在web.config中重新创建相同的行为,但不知道从哪里开始转换/重写.htaccess文件。我发现IIS7及以上版本可以使用URL重写模块导入Apache.htaccess规
我刚刚在IIS7上本地设置了我的站点,需要在web.config中重新创建相同的行为,但不知道从哪里开始转换/重写.htaccess文件。我发现IIS7及以上版本可以使用URL重写模块导入Apache.htaccess规则
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
生成以下web.config文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}.php" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="{R:1}.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>