【问题标题】:IIS + PHP - Url Rewrite IssueIIS + PHP - 网址重写问题
【发布时间】:2014-09-26 10:20:58
【问题描述】:

首先我的英语不太好,那是因为我找不到我找到的东西。

好的,这是我的 web.config 规则

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
            <rule name="Imported Rule 1">
                <match url="^Girisyap$" ignoreCase="true" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Rewrite" url="giris.php" />
            </rule>
                <rule name="Imported Rule 2" stopProcessing="true">>
                  <match url="^([0-9a-zA-Z-_/]+)$" />
                  <action type="Rewrite" url="Sayfalar.php?Sayfa={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
        <directoryBrowse enabled="false" />
    </system.webServer>
</configuration>

使用此规则,当我尝试访问 http:// localhost:84/Girisyap 时,它也会显示 giris.php。
如果我访问 http:// localhost :84/Around 向我展示了 Sayfalar.php?Sayfa=Around 以及。
但是当我访问 http://localhost:84/ 时,它给了我 403.14 - 禁止错误.因为我没有使用 index.php 或 default.php,我不想要它。
如何显示 'Sayfalar.php?Sayfa=' (Sayfa 为空) 访问 http://localhost:84/ 为好

【问题讨论】:

    标签: php iis url-rewriting


    【解决方案1】:

    在 Apache 中,您会在 htdocs 中找到一个 index.php 文件,它将默认网站设置为 xampp 文件夹(默认情况下)。也许您必须在 IIS 中找到相同的情况。尝试将默认网站编辑到您网站的目录,也许您可​​以将您设置为绑定到其他端口(如您所愿,并且可以使用 = 84)。祝你好运,它对我有用。 将此代码添加到 web.config 文件中

    <system.webServer>
         <defaultDocument>
            <files>
              <add value="Login.aspx" />
            </files>
         </defaultDocument>
         <directoryBrowse enabled="false" />
    </system.webServer>
    

    注意:Login.aspx 是一个示例。将其更改为您的默认文档。

    【讨论】:

    • 我没有网站目录问题。我只是在尝试不收到 403 错误。而不是这个,我想显示'Sayfalar.php?Sayfa='。有没有办法在 web.config 文件中做到这一点。
    • 那是目录列表问题。它被某些东西或者可能是确认拒绝了。如果您正在寻找 web.config 文件中的错误,请尝试添加代码
    猜你喜欢
    • 2011-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    • 1970-01-01
    • 2012-05-25
    相关资源
    最近更新 更多