Valter
Valter

Reputation: 2899

IIS 8.5 Redirecting

I have a basic project running on IIS 8.5

sites 
-> test.domain.com
--->virtualPath
----->index.html

On the browser when enter https://test.domain.com/virtualpath, it is return 301 (redirect) to test.domain.com/virtualpath/

I don't have any URL Rewrites in IIS configuration. Just trying to figure out why it is redirecting to test.domain.com/virtualpath/

How can avoid this 301 redirect?

Upvotes: 0

Views: 79

Answers (1)

Joel
Joel

Reputation: 6183

The short answer is that IIS doesn't handle extensionless URLs very well. URLs are processed based on the file extension, otherwise it's presumed to be a directory you're looking to get served. The normal convention however is to omit the index.html file. But most services like IIS take that for granted, and if nothing is specified, it will lookup if there's a /index.html.

Lets take a simple example:

google.com

In reality what's being served to you is:

google.com/index.html

Lets take your request as an example https://test.domain.com/virtualpath

test.domain.com
- virtualPath/
  - index.html

As you can see, you're essentially trying to get a directory rather than a specific file. It's up to IIS to try to find and understand that you want a file instead of a directory now. That's why you're getting a 301. It's redirecting you to the /index.html file.

Upvotes: 1

Related Questions