0

UPDATE

After enabling direcorty listing it seems to have worked but now im running into another error.

Resource interpreted as Stylesheet but transferred with MIME type text/html

I'm trying to rewrite a URL to take content from the absolute directory.

Let's assume my URL was https://somesite.com/a <-- absolute path

This directory consist of files like index.html, contact.html and folders like css,js,img

But i want to access this directory with a URL like
https://somesite.com/a/somename/index which should take me to
https://somesite.com/a/index
but it should also keep the parameter somename in the URL therefore redirecting is not an option, this is because i need to use the Referrer Url later onwards from backend code.

My Rule

<rule name="StoreRewrite" stopProcessing="true">
      <match url="^a/([^/]+)/([^/]+)" />
         <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
         <action type="Rewrite" url="a/{R:2}" />
 </rule>

The above redirect works but it doesn't load the additional content inside the html files,
like js,css files which are all relative to the html file.

The below error is show when i enter the url https://somesite.com/a/someprofile/contact
The page from a\contact is displayed but not its relative content. The console is filled with this error

  Failed to load resource: the server responded with a status of 403 (Forbidden)

The above is shown when i enter the URL

user8222166
  • 69
  • 1
  • 8
  • 1
    find the http sub-status code for the 403s in the http logs on the IIS server and add it to your question. When using rewrite or redirect using relative links in the page becomes tricky. – Peter Hahndorf Apr 23 '19 at 21:06
  • make sure that static content role is installed.and check that you give full control to IIS_IUSRS and IUSR to access site folder.try to add authorization for all the folders that contained the CSS, JS and images. – Jalpa Panchal Apr 24 '19 at 07:35
  • @JalpaPanchal Static content is installed and yes all the authorization stuff is done. It works when i access it with the normal url. – user8222166 Apr 24 '19 at 10:01
  • @PeterHahndorf After looking into the sub status code 14 i fixed it by enabling direcotry browsing on iis. But now i run into another error for the CSS and JS files as thier content type is set to text/html. Resource interpreted as Stylesheet but transferred with MIME type text/html: "https://autodevserver.com/a/vendor/" – user8222166 Apr 24 '19 at 10:09
  • in iis setting check that .css extension has text/css mime type [image link](https://i.postimg.cc/HLxWQXtD/css.jpg) or not.also check response header has Content-Type: text/css.[link](https://stackoverflow.com/questions/22631158/resource-interpreted-as-stylesheet-but-transferred-with-mime-type-text-html-see/34669257) . – Jalpa Panchal Apr 25 '19 at 06:07

0 Answers0