Trying to map subdomain to another using ISAPI Rewrite on IIS 6 - iis

I've been experiementing with URL rewriting in IIS 6 and 7. On IIS 6, I've been using ISAPI Rewrite 3 and am trying to map URLs for one subdomain to another e.g.
http://subdomain1.domain.com/*
would be mapped to:
http://subdomain2.domain.com/*
I've tried to achieve this using:
RewriteEngine on
RewriteCond Host: subdomain1.domain.com
RewriteRule (.*) subdomain2.domain.com/$1
but nothing seems to happen or show up in the IIS log or rewrite.log. I must be missing somethin to enable logging here - any ideas? Also, if anyone could suggest why my rules don't seem to be working it would be much appreciated.
One further question (sorry!) - was wondering on IIS 7 using the rewrite module, I can use the rewrite rules to redirect to content hosted on another instance of IIS (on a different server machine) but can't use the rewrite action to simply mask the URL - is this possible? At the moment, I'm just getting a 403 - forbidden error.
Many thanks for your help.

With regards to your second question about rewriting on IIS 7, you can use the Application Request Routing module to set up a reverse proxy between 2 servers so that content requested from the first server is seamlessly served from the second server.
http://learn.iis.net/page.aspx/489/using-the-application-request-routing-module/

Related

How to redirect a URL for example (www.foobar2.com) to another URL (www.foobar.com) using htaccess file

I am setting up a link which should open another website. For example, if a browser is opening up www.foobar2.com, it should open www.foobar.com without changing the URL. I found out that it can be done using .htaccess file. Currently, if I open, www.foobar2.com, it redirects to www.foobar.com but the URL also changes to www.foobar.com. But I want that URL should not change. What do I need to do?
I tried this which isn't working -
RewriteCond %{HTTP_HOST} ^www.foobar2.com
RewriteRule ^(.*) http://www.foobar.com [P]
Please help me with this.
Thanks :)
Since the http host the request is sent to is always that shown in the URL (for obviousl reasons) you need to implement a proxy feature, this cannot be done using pure rewriting or redirecting.
The apache http server offers a proxy module for this, it can be either used standalone or integrated into the rewriting module. However you want to use it you need to take care that the module is actually loaded first. It consists of two submodules, the core proxy module and the proxy_http module in this case.
Now you can implement a ProxyPass directive for the URL you want to fetch from the other host:
ProxyRequests off
ProxyPass / https://www.foobar.com
ProxyPassReverse / https://www.foobar.com
(yes, that is an off in the first line above)
This rule needs to be implemented in the http host www.foobar2.com. It will make an internal sub request to www.foobar.com for each incoming request (since it masks the root (/) and deliver the response it receives back to the originally requesting client.

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.

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

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.

'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