The website where this occurs is set up as follows.
wwwroot
|
+--testproject
|--web.config
+--public
| |
| |--index.php
| +--assets
| |
| +--js
| |
| |--testscript.js
+--app…
The contents of web.config file are
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite routed access to assets javascript" stopProcessing="true">
<match url="^(.*)(/js/[a-zA-Z0-9]*.js)$" />
<action type="Rewrite" url="public/assets{R:2}" appendQueryString="false" logRewrittenUrl="true" />
</rule>
<rule name="Rewrite requested file/folder to index.php" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="public/index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The contents of index.php are
<html>
<body>
<h1>Testpage</h1>
<h3>Text from javascript testscript.js</h3>
<div id="testdiv"></div>
<script src="js/testscript.js"></script>
</body>
</html>
The contents of testscript.js are
var e = document.getElementById("testdiv")
e.innerHTML = "Lorum ipsum...";
Question: why does “http://localhost/testproject/users” give an error message when loading the JavaScript, but at “http://localhost/testproject/users/23” the script is started correctly?
System info: Windows 11; IIS 10.0; IIS Rewrite Module 2.
1