How to implement URL rewrite in classic ASP using custom 404 page? - iis

My web host told me that they are using Windows IIS (not sure about the version) and are unable to implement a URL rewrite for me. I am now looking at alternative ways to do this. Obviously, I don't have access to the IIS server. I read somewhere that using a custom 404 page, I am able to implement a URL rewrite from my end using classic ASP.
I want to do a URL rewrite for subdomain.mydomain.com to www.mydomain.com/subdomain.
I am a bit lost about the steps that must be taken to implement URL rewrite. Can someone take me through the steps?
Thanks

Request.ServerVariables("HTTP_HOST") will give you the subdomain.
if Request.ServerVariables("HTTP_HOST")="subdomain.domain.com" then
response.redirect("http://domain.com/subdomain")
end if

You can get URL Rewriting on IIS6 with IIRF - it's free. If your web host can install it for you., it's easy to get rewrites on IIS. If the web host has IIS7 or later, then they can use the URL Rewriting module that's included in IIS7.

Related

URL and Port redirect on IIS

I'm struggling with an issue in IIS 8.5 which is about redirection and rewriting, but couldn't get a solution yet
we have an application driven Webpage running on IIS, but is not manageable.
This application can attached by browser using
http:// 10.172.100.242:81/appname/object?parameter
which is not really customer friendly. Up to the "?parameter" the URL is steady, parameter is changing.
I would prefer to have this url shown to the customer as
http:// appname.domain.com/parameter (best solution) or
http:// appname.domain.com/object?parameter
The combination of redirect and rewrite is too much for my knowledge
The rules I tried didn't work and now I have the hope to get some help from guys with better knowledge than mine...
Thanks in advance
First create a new website in IIS. Then configure as follows.
Inside the website create a folder called "parameter"
Select the "parameter" folder and set the redirect as show in the picture 2

How to configure IIS Url Rewrite

I'm trying to achieve wildcard hostname mappings in IIS 8.5. As they don't exist, I'm trying to use URL Rewrite.
I have two formats of URL,
<anything>-foo.mydomain.com
<anything>-bar.mydomain.com
I want to map these to two different sites in IIS, for example
<anything>-foo.mydomain.com --> foo.mydomain.com/<anything>
<anything>-bar.mydomain.com --> bar.mydomain.com/<anything>
I'm trying to configure a URL Rewrite rule at the machine level, but I've got some problem.
If I set it to Redirect it works. If I set it to Rewrite I get an IIS 404.4.
Can anyone shed any light on this?
Here are my settings:
http://cl.ly/a6tK
You can only rewrite the URL to the same site and same application pool. For example:
http://foo.com/bar to http://foo.com/
You need to install Application Request Routing and enable Proxy. Then it will work with URL rewriting to remote servers (regardless where or what they are) since the routing will take care of that.
http://www.iis.net/downloads/microsoft/application-request-routing

How to get Dynamic URL with the help of Web.Config and PHP

Suppose i have
3 php pages
www.example.com/page1.php?var1=data1&var2=data2&var3=data3
www.example.com/page2.php?var1=data1&var2=data2&var3=data3
www.example.com/page3.php?var1=data1&var2=data2&var3=data3
For good SEO . I need URL like
www.example.com/page1/data1-data2-data3
www.example.com/page2/data1-data2-data3
www.example.com/page3/data1-data2-data3
i need all the variables for proper functioning of php pages. Some suggests me to use htaccess file but my website is on godaddy windows hosting so htaccess doesn't work ..
.
Go Daddy allows you to use URL rewrite module if you are on windows hosting plan. You can achieve the desired effect with URL routing.
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module should give you all the information you need for setting up the appropriate rewrite rule.

IIS URL Rewriting for all Inbound URLs?

Hopefully a simple question although one I have found impossible to answer myself using the Googles!
I have a website on IIS with the URL http://www.contoso.com/ which points to C:\www\public\
There has been a forced directory restructure so now all of the data (Default.aspx, Product.aspx, etc.) that originally resided in C:\www\public\ now resides in C:\www\public\en\ie\ - however, the IIS website document root is still C:\www\public\
So, essentially, I have a lot of inbound links to http://www.contoso.com/Product.aspx?id=1 (etc.) which are now returning 404 errors - the correct link is now http://www.contoso.com/en/ie/Product.aspx?id=1
Please consider that I can make no changes to the directory structure or the IIS document root... so I must solve this issue using URL rewriting.
Is it possible to capture all requests to contoso.com/* and rewrite them to contoso.com/en/ie/* ??
As Ivo suggests, using url rewriting you can set up inbound rules that match the old url pattern and redirect to the new pattern
http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
Change the root directory of your website from C:\www\public\ to C:\www\public\en\ie\ and everything should be fine.
If you cannot do this for any reason, make a custom 404 page and rewrite to url in there and redirect with a 301
See: http://searchengineland.com/url-rewriting-custom-error-pages-in-aspnet-20-12234

'Masking' external url links using RewriteProxy derictive

I have a simple rewrite rule that writes to an external domain using the Helicon Isapi_Rewrite 3 RewriteProxy derictive.
Example: RewriteProxy blog http://blog.com
However, links on the external site are not masked by the proxy as I would have expected them to be. They are still pointing to http://blog.com/link1 rather than http://mysite/blog/link1.
Could anyone point me in the right direction of a solution to this?
Thanks
This discussion on the Helicon Tech forums addresses the same issue.
http://www.helicontech.com/forum/8460-rewrite_proxy_to_2d_machine.html
The first example provides code for ISAPI Rewrite 2, but the thread includes ISAPI Rewrite 3 syntax further down the page. Here's an adaptation of their version 3 code for your example.
RewriteEngine on
RewriteBase /
RewriteRule ^blog$ http://mysite/blog/ [NC,R=301]
RewriteProxy ^/blog(/.*)?$ http\://blog.com$1 [NC,U]
(This is untested because I am running ISAPI Rewrite 2.) Note that I hit some snags when attempting to reverse proxy another site under my "main" domain. You might discover these issues as well.
1) Non-Relative Links
Unless the application has been coded from the ground up to assume reverse proxying, I found it likely to break. A bare-bones HTML page using all relative links like will work. However, serving HTML through a reverse proxy that contains this code will map to http://mysite/page_from_the_root.html. ISAPI Rewrite does not know to intercept that request, but it would proxy content if the user's browser hit http://mysite/blog/page_from_the_root.html
2) Cookies
Blog.com might write cookies from the blog.com domain. A page served through the MySite domain might not be able to access these cookies, depending on the user's browser settings.
3) JavaScript and AJAX
4) SSL Certificates

Resources