Landing page throws 404 error but inside pages works - iis

When I type the URL as www.example.com, it throws the following error message.
404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily
unavailable.
but when I type the URL as www.example.com/index.cfm, it works. Please advise what can be the problem and how can I solve this issue.
When I open the URL www.example.com from the server, it throws different error message.
HTTP Error 404.17 - Not Found The requested content appears to be
script and will not be served by the static file handler.

TechNet has an article on this, what you want to do is add a default document. By default IIS doesn't look for .cfm files as "default" files like index.html, so you have to configure it to do that.
From TechNet:
With the GUI
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
In Features View, double-click Default Document.
In the Actions pane, click Add.
In the Name box, type the file name that you want to add to the list of default documents and then click OK. This file name will be added to the top of the default document list.
Optionally, select a default document in the list and in the Actions pane, click Move Up or Move Down to change the file's precedence.
Optionally, select a default document in the list, and in the Actions pane, click Remove to remove any file names that you do not want to use as default documents.
With the CLI
To add a file name to the list of default documents, use the following syntax:
appcmd set config /section:defaultDocument /+files.[value=' string ']
The variable string is the file name that you want to add to the list. For example, to add a file named home.html to the default document list, type the following at the command prompt, and then press ENTER:
appcmd set config /section:defaultDocument /+files.[value=' home.html ']
To remove a file named home.html from the default document list, type the following at the command prompt, and then press ENTER:
appcmd set config /section:defaultDocument /-files.[value=' home.html ']
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

Related

IIS | how can i change IIS log files directory names

**How can i change default logfiles directory name for all sites.????
for example %SystemDrive%\inetpub\logs\LogFiles**$SITE_NAME**
Who can help me?
**
i have tried to write Directory path with VARIABLE, but didn't work
As Lex Li said, I don't think it is necessary to modify the IIS log folder name.
The numbers on the IIS log default folder correspond to the ID of each site in IIS. Open the IIS manager, double-click the Sites node, you can see the IDs of all sites.
You can also run the following command to return the ID of the site: C:\Windows\System32\inetsrv>appcmd list site.
If the ID of the site is 1, the corresponding log folder name is W3SVC1, and the ID=2 corresponds to W3SVC2, etc.

IIS - ignore/deny access to specific pages

I have hosted an asp.net project in IIS and I want to restrict logins to some pages/folders.
I want to restrict all the users to not open some directory files using url.
They have to be able to only access the localhost/mypage/home and localhost/mypage/login. but if I try something like: localhost/mypage/resources/importantNotes.json everyone can open it! So I want somehow to redirect/deny access to it.
Also I want to not "totally" ignore that typical path because I need that resources folder later in my code.
What I have tried:
HTTP-Redirect, this works well, it redirects to specific page but I loose total access to the files I have on that specific path!
I have also tried with filteringRules but still the same result, I loose total acces to that specific resource folder!
What should I try or what am I missing here?
Below is the approach to block accessing folder and its contents using the URL Rewrite module.
You could select your site, open the URL Rewrite module.
Click the Add Rules option, select Request Blocking rule template and click the OK button.
Set * as pattern.
Set {REQUEST_URI} as Condition input. Set /test_folder/ as pattern. You could modify it and specify your own folder name here.
Set Custom Response as Action type. set Status code as 403.
click the Apply button and restart the site.
Output:
To block files in the folder, you need to set the pattern as /test_folder/*.
Output:

Remove subdirectories from URL on IIS

I currently have a website running on IIS Windows Server 2019.
The website's url is : https://mywebsite.com/Sub1/login
When i get to https://mywebsite.com i obiously dont get the connexion form.
I would like to get rid of /Sub1/login and turn into https://mywebsite.com.
I tried using URL Rewrite but i don't get the syntax. Could any please help me ? :)
As Lex Li said, you can do this by setting the default document.
In IIS Manager, click the server name node, and then scroll to locate the Default Document icon.
Double click Default Document.
In the Actions pane, click Add.
In the Add Default Document dialog box, type the full filename of the default page.(such as login.aspx)
Click OK.
But the premise is that your default page needs to be placed in the root directory. This way you can directly access your default page by typing https://mywebsite.com in your browser.
In addition, you cannot use the Rewrite operation to remove the path part of the URL, because Rewrite does not change the address in the browser.

How to sort the files by "Data Modified" in IIS Server 7.5?

I have enabled 'Directory Browsing' for only "logs" folder of my Web Application hosted via IIS 7.5
Whenever I type www.domain.name//logs in my Browser, I could see the log files listed.
I would like to see the files sorted by 'Date Modified',i.e, the latest log must come at top and the oldest log must be present at the bottom.
How to go about this?
Is this possible in IIS 7.5 in first place?
As far as I know there is no out of box setting/configuration available with which you can sort directory/file list displayed in browser. Of course that doesn't stop you writing your own custom HTTP module. Here is broad idea.
Intercept directory requests to your application.
In Http module handle OnPreRequestHandlerExecute event.
In even handler get directory/file list.
Create nicely formatted page which will display list from step 3. Here you can format/sort way you like it.

IIS websites inheriting settings from unknown origin

I am dealing with an IIS server that hosts 900+ websites. There are about a dozen that do not contain any web.config file, yet on their settings page > HTTP Redirect section the "redirect requests to this destination" is checked and a URL to one of the hosted websites is present inside the textbox below it. I cannot figure out where the checkbox's true value and the URL is coming from.
Note: If I turn off the checkbox a web.config file is created with the following line:
<httpRedirect enabled="false" />
While this kind of works it is not an ideal solution.
In IIS Manager:
Click on the website
Open "Configuration Editor" under the "Server Components" section
In the "Section" dropdown choose "system.webServer/httpRedirect" (or whichever section that has issues)
In the "From" dropdown choose "ApplicationHost.config"
Set or unset the properties
Click "Apply"
You can now edit the website's web.config file manually or use the above interface.

Resources