从Windows服务器宿主隐藏.php扩展名
我正试图从基于窗口的主机中隐藏.php扩展名 我正在使用web.config进行尝试从Windows服务器宿主隐藏.php扩展名,php,iis,url-rewriting,web-config,window-server,Php,Iis,Url Rewriting,Web Config,Window Server,我正试图从基于窗口的主机中隐藏.php扩展名 我正在使用web.config进行尝试 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rule name="hide .php extension" stopProcessing="true"> <match url="(.*)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rule name="hide .php extension" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.php" />
</rule>
</rewrite>
</system.webServer>
</configuration>
显示404错误,请说明问题所在
谢谢。我也在Windows IIS环境中开发PHP,您的规则在我的环境中运行得非常好。检查我的web.config,它对我来说非常适合,也许这对你有帮助
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<globalization fileEncoding="UTF-8" responseEncoding="UTF-8" culture="tr-TR" uiCulture="tr-TR" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="hide .php extension" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.php" />
</rule>
</rewrite>
<handlers>
<add name="PHP" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\php\php-cgi.exe" resourceType="File" />
</handlers>
</system.webServer>
</configuration>
PS:如果这对您不起作用,您可以为您的Windows操作系统检查
事件查看器
这条规则对我的环境很有效。我认为这与你的重写规则无关。你检查过事件日志了吗?您的php处理程序如何为iis工作,应该是fast cgi?感谢您的回复,当我运行给定代码时,我发现错误“HTTP错误500.19-内部服务器错误”您的服务器是共享主机吗?你能检查一下这个链接的结果代码吗?我想它是IIS8.0