【问题标题】:IIS rewrite rules - href and src not workingIIS 重写规则 - href 和 src 不起作用
【发布时间】:2017-03-08 03:10:31
【问题描述】:

我正在就我的用户友好 URL 寻求帮助。我正在尝试在 IIS 中使用“重写规则”。重写这个 PHP 文件实际上是有效的,即使传递了 id 参数并呈现了文章,但是我们在链接中的 href 和脚本标签中的 src 具有错误的地址,因此它们无法加载这些资源。

        <rewrite>
            <rules>
              <rule name="Rewrite to skaly.php">
                    <match url="^skaly$" />
                    <action type="Rewrite" url="skaly.php" />
                </rule>
                <rule name="Rewrite to skaly2.php">
                    <match url="^skaly/([0-9]+)$" />
                    <action type="Rewrite" url="skaly.php?aktualita={R:1}" />
                </rule>
            </rules>
        </rewrite>

控制台日志打印屏幕:

      <link rel="stylesheet" href="css/font-awesome-4.6.3/css/font-awesome.min.css">
      <link rel="stylesheet" type="text/css" href="css/styles.css" />
      <link href="css/lightbox.css" rel="stylesheet" type="text/css"/>
      <link rel="import" href="DESYREL_.ttf">

感谢您的建议。

【问题讨论】:

    标签: php mod-rewrite iis href src


    【解决方案1】:

    您日志中的每个 URL 路径都以 /skaly/ 开头,但我猜这些资产是相对于您的 Web 根目录的。在您的 URL 前加上 /,例如/css/styles.css,因此它们成为根相对。

    【讨论】:

    • 非常感谢,我很傻 :D 非常感谢 :D
    猜你喜欢
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    • 1970-01-01
    • 2015-07-10
    • 2013-08-14
    • 2020-01-18
    • 1970-01-01
    相关资源
    最近更新 更多