Search code examples
phpmod-rewriteiishrefsrc

IIS rewrite rules - href and src not working


I am asking for help with my user friendly URL. I am trying to use "rewrite rules" in IIS. Rewriting to this PHP files actually works, even id parameter is passed and article is rendered, but our hrefs in links and src in script tags are having a bad address, so they fail to load those resources.

        <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>

Console log printscreen: Console log printscreen

      <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">

Thx for your advice.


Solution

  • Every URL's path in your log begins with /skaly/ but I'm guessing those assets are relative to your web root. Prefix your URLs with a /, e.g. /css/styles.css, so they become root-relative.