gpt4 book ai didi

.htaccess - URL重写Azure PHP?

转载 作者:行者123 更新时间:2023-12-02 23:32:47 25 4
gpt4 key购买 nike

我在 Azure 上创建了一些 PHP 应用程序,但这是我第一次将 IIS 用于我的 PHP 应用程序。我知道如何在 Apache 上使用 .htaccess 进行 url 重写,没有问题。但是如何在 Azure IIS 上实现这一点。这是我的 Apache .htaccess。

.htaccess

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

最佳答案

您需要使用 Web.config 文件并使用 <system.webServer><rewrite>在此范围内的规则。

您需要在 web.config 中使用以下内容从 .htaccess 复制上面的代码:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

关于.htaccess - URL重写Azure PHP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38030555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com