Custom 404 not found page in iis 7 for Classic ASP - iis-7

I installed windows 2008 server integrated iis 7.0
1 day ago, i use windows 2003 and iis 6.0
with windows 2008 server, everything is alright except one thing.
in 2003-iis6 i could use custom 404 pages to handle for url friendly sites.
example i could set custom404.asp as custom 404 pages(execute url)
in 2008, i can't do it.
when i set custom 404 page as /custom404.asp, nothing happens.
in custom error pages it says this is for asp.net
how can i do it?

On the "Error Pages" section in IIS manager select the "Edit Feature Settings..." under the Actions section. Ensure that "Custom error pages" is selected.

the webconfig file below fixed the problem.
i share in case anyone needs
save the code as web.config and move it to main site folder
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/default.asp" responseMode="ExecuteURL" />
</httpErrors>
<rewrite>
<rules>
<rule name="MyURLCleaned" enabled="false" stopProcessing="true">
<match url="^([^])+" />
<conditions>
<add input="{REQUEST_FILENAME}" />
</conditions>
<action type="Rewrite" url="/default.asp?{R:0}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="static">
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Related

How to config Vue 2 application on IIS server?

I need help with config IIS server and Vue 2 application, I just installed vue 2 application with production build on Windows IIS 7 server, and all work fine, only one thing is not working:
When I try to open any page with link "example mysite.com/somepage" which written in vue-router i see 404 error, but if I click on menu link work fine, if you type just main url mysite.com it will open, but any another routes not working!
I think I need to setting my httpRedirect or something like this!
From your information I'm assuming you're using the history mode, here's the one I've been using, and you can reference on here:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.html" />
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
</httpErrors>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
As noted in the vue-router documentation, in order to use history mode, you need to do the following:
Install IIS UrlRewrite.
Drop a web.config file into the root of the project. See the vue-router documentation for an example web.config file.

Blocking invalid URL and redirect to homepage in IIS

Currently I am using the web hosting service provided by another company. It uses IIS 7/IIS 8 and allows customers to modify web.config according to their needs.
Suppose I have set up two valid URL:
http://www.example.com
http://dev.example.com
Now, when I try to access http://abc.example.com, HTTP Error 403.14 - Forbidden is returned; and if I then try to access http://www.example.com/abc, HTTP Error 404.0 - Not Found is returned.
How can I configure web.config such that users will be redirected to http://www.example.com when they are trying to access an invalid URL?
I have tried to use the snippet provided by the company but without success:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical Host Name" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
In system.web in webconfig tag add this tag
<customErrors mode="On" defaultRedirect="~/Home/Index">
</customErrors>
This will redirect you to the home page whenever an error occured
You can be more specific with redirection by adding in customErrors tag
<error statusCode="401" redirect="/error/otherpage"/>
This will indicate the page that you will be redirected to when 401 error occurs

Url Rewrite with Web.config not working with IIS express

I need to use Url Rewriting, so I made a test case, in Web.config, to check if it's working:
Web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="Fail bad requests">
<match url=".*"/>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
... other stuff
</system.webServer>
I was expecting any localhost:3285 to abort and fail, but it entered correctly.
I'm using Url Rewrite with IIS Express.
I am guessing your problem is browser caching. I have found that if I open a web page in IE, then add URL rewrite rules (requires stopping IIS express), then open the same page again in IE it still loads the page (and it appears the abort rule is not being applied). But, if I clear the IE browser cache and refresh the page the abort occurs.
Here is a full Web.config example that works for me
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Fail bad requests">
<match url=".*"/>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Your example should work because the URL rewrite module is built into the current version of IIS Express:
http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-express-overview

Permanent redirection in asp.net when old page not exist?

Hope you all are spending a great time in this forum. Today I joined this forum and come with a problem. My problem is that...
Recently i created a website and when I create its pages then 1 page name is misspell. Now I want to redirect this page to real page name. I am using this code:
<system.web>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"></modules>
<httpHandlers>
<add verb="*" path="misspell url " type="UrlRedirection" validate="false" />
</httpHandlers>
</system.web>
This code is fine in local server but when I upload this code on server its show 500 internal server error.
Points:
• We used godaddy hosting , IIS 7 .
Need help!
Thanks in Advanced.
Good news, you are using IIS7 and your GoDaddy hosting supports the UrlRewrite module:
http://support.godaddy.com/help/article/5443/microsoft-url-rewrite-module
This means you do the following:
Delete the <httpHandler> <add /> that you have set up.
Find <system.webServer> in your web.config
Paste this in between the start and close tags:
Code:
<rewrite>
<rewriteMaps>
<rewriteMap name="StaticRewrites" defaultValue="">
<add key="/oldurl.aspx" value="/newurl.aspx" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="RewriteMap Rule">
<match url=".*" />
<conditions>
<add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" />
</rule>
</rules>
</rewrite>
You can add as many of these rows as you like if you want to redirect several pages:
<add key="/oldurl.aspx" value="/newurl.aspx" />
I just double checked this on my server and it produces a 301 redirect (which is a permanent, seo friendly redirect).

Custom 404 page not executing for missing ASPX pages - IIS 7,5

Using IIS 7.5 in classic mode (as we're using SiteCore) with a WebForms app (.Net 3.5), we have error pages defined as
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/Error/404.aspx" responseMode="ExecuteURL" />
</httpErrors>
Now, for files of a non .Net type that aren't found when requested , the custom error page isn't being displayed, and a standard 404 status type is returned. If we use a custom error page with a .htm extension (e.g. path="/Error/404.htm"), then it is displayed!
From what I've read the xml is correct, and should work for non .Net file types. I have no section in my web.config. Sounds like something else e.g. SiteCore maybe affecting things - let me know if you need any more info.
404 custom page - works .aspx & non .aspx URLs
Works on GoDaddy Shared Windows Hosting (IIS7 .Net4)
Create a 404.html or 404.aspx file on your local main folder in your shared GoDaddy hosting.
-Web.Config File-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="404.html or 404.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Have you tried adding this 404 page to IIS -> Website properties -> Custom Errors tab, then under 404, point to the web page that you would like to show up when a file is not found?

Resources