ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > Living Room

URL Rewrite Problem

(1/2) > >>

BGM:
Hello, folks.

I need some help with a problem on my webserver involving url-rewrite and redirection in my IIS7.  I made a post at ServerFault, but noone is hardly even viewing it.

Here is the contents of my post there:

We have our own domain and have several subdomains. One of the sites needs to be accessed only via SSL, but people are allowed to type http and still arrive there. The URL-Rewrite forces the http into https.

So my two subdomains are: sub1.domain.org and sub2.domain.org.

Thus, if I type


--- Code: Text ---http://sub1.domain.org/page_on_domain1
it is rewritten to


--- Code: Text ---https://sub1.domain.org/page_on_domain1
-which is correct. But if I do this (which is not possible - page_on_domain1 does not exist on sub2.domain.org:


--- Code: Text ---https://sub2.domain.org/page_on_domain1
My url-rewrite rule seems to work properly, but I want that last address to give me an error page instead, since the page doesn't exist on that subdomain.

I am testing this in Firefox on Windows 7 x64 Pro.

My url-rewrite rule is as follows (I am doing it through the IIS7 GUI):


--- Code: Text ---Requested URL:  Matches the Pattern:  (*)  Using Regular Expressions (ignore case)Conditions:  Match All:  Input:  {HTTPS}  Matches the Pattern:  ^Off$Redirect URL:  https://sub1.domain.org/{REQUEST_URI}
Now, I've tried changing the Requested URL Pattern to: .*sub1.domain.org/.* but the regex tester in IIS7 says it doesn't match against https://sub1.domain.org - I don't understand that.

How can I keep the rewrite of http to https for sub1.domain.org, but not have any effect at all on sub2.domain.org ??

I've been stuck on this for a long time.  This is my first ever post to the Living Room.
Thank you!

wraith808:
To get more traction, I'd suggest copying the text of your question here, in addition to linking to it.

Renegade:
URL rewriting is a part of the DNN framework. You can likely look into that and just rip it out and use it.

They key to URL rewriting in IIS 7+ is making it happen at the application layer. Once you've got it there, you're golden.

BGM:
@Renegade,  I have a url-rewrite module already installed and working in my IIS.  I can't figure out how to get the settings and regex right.

Renegade:
@Renegade,  I have a url-rewrite module already installed and working in my IIS.  I can't figure out how to get the settings and regex right.
-BGM (June 21, 2014, 08:53 AM)
--- End quote ---

I don't know your system there, but it looks like a simple conditional will work to solve that.


--- Code: C# ---if (condition){        // send to https} else {        // send to http}
Can you put that in the global.asax file? Or wherever the regex logic is?

There are some very good, robust code bases out there that can help. DNN might be a good source to look at.

Navigation

[0] Message Index

[#] Next page

Go to full version