IIS Url Rewrite results in 403 Forbidden

2019-08-19 01:33发布

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

0条回答
登录 后发表回答