Php 是否正在将.htaccess转换为Azure的web.config?
我这里有一个.htaccess文件,我需要将其转换为web.config以与Azure一起使用。以下是htaccess文件:Php 是否正在将.htaccess转换为Azure的web.config?,php,.htaccess,azure,web,config,Php,.htaccess,Azure,Web,Config,我这里有一个.htaccess文件,我需要将其转换为web.config以与Azure一起使用。以下是htaccess文件: Options +FollowSymlinks Options -Multiviews ErrorDocument 404 /error-404 RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [NC,L] 我已经将
Options +FollowSymlinks
Options -Multiviews
ErrorDocument 404 /error-404
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [NC,L]
我已经将其转换为web.config文件,但它不起作用。它只是抛出了一个404错误NotFound。以下是web.config文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule 1C" stopProcessing="true">
<match url="!.*\.php$" ignoreCase="true" />
<action type="Rewrite" url="/%{REQUEST_FILENAME}.php". />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<add value="test.php" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
除了重写之外,这个文件的所有功能都正常。只需要帮助就可以在Azure中显示没有.php文件扩展名的页面。有关
ErrorDocument 404/error-404
,请参阅下文
<system.webServer>
<httpErrors>
<remove statusCode="404" />
<error statusCode="404" path="/error-404" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule 1C" stopProcessing="true">
<match url="!.*\.php$" />
<conditions logicalGrouping="MatchAll">
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
有关重写url的信息,请参见下文
<system.webServer>
<httpErrors>
<remove statusCode="404" />
<error statusCode="404" path="/error-404" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule 1C" stopProcessing="true">
<match url="!.*\.php$" />
<conditions logicalGrouping="MatchAll">
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>