URL redirection if no extension

I want to redirect as follows:

http://www.example.com/something1 http://www.example.com/something2 http://www.example.com/something3 

to

 http://www.example.com/something1.aspx http://www.example.com/folder/something2.pdf http://www.example.com/something3.aspx?id=10 

and still show the original url in the browser (under the hood redirection)

Environment - IIS 6 / Asp.Net 3.5 on Windows Server 2003 Service Pack 2

How can I do this using web.config or IIS.

I know how to handle redirects if I can map the extension to aspnet_isapi.dll and use Context.RewritePath(string) , but I don't know how to do this for URLs that don't have extensions.

+4
source share
3 answers

If you can upgrade to ASP.NET 4, then there is much more support for loose URL rewriting.

However, if you need to use ASP.NET 3.5 / IIS6, you can use the ScottGu blog post here:

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

+1
source

If you must adhere to the IIS6 platform and / or older .Net, there is a great tool from Helicon Tech that implements the apt style.htaccess rules for the Microsoft IIS platform. They have a paid version, but also a free version. The free version is limited only to processing one rule file, while the paid version can have many rule files that can be nested in a hierarchical directory structure.

I have been using the free version for a couple of years and it works great. The only catch is that you must have access to the server (you cannot do this in a shared hosting environment if your host does not already support it).

HeliconTech ISAPI Rewrite

EDIT: To clarify, it supports all major types of redirects, including proxying content from one URL to any desired presentation URL. Proxy Sample Documentation

+1
source

In IIS, configure a custom 404 error page, for example. error404.aspx, which is located on your site. Within error404.aspx, you can access the original URL, I think its Request.RawUrl (you may have to check this), then you can build a redirect or transfer depending on what you prefer.

This may help Access the source URL on the IIS7 404 redirect page

How can this be http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/80cb8d8d-8fd8-4af5-bb3b-4d11fff3ab9c.mspx?mfr=true

0
source

Source: https://habr.com/ru/post/1388907/


All Articles