Removing www from url in IIS 6 - asp.net

I have an SSL certificate setup for www.mydomain.com. I'm having a strange issue in IIS 6. When I navigate to www.mydomain.com everything works fine. Since the www. part is what my ssl certificate is registered under I get no issues. Hwoever, all of my links in my site take me to mydomain.com/mylink which causes a cetificate error because it's not prefixed with www. My website is ASP.Net and all my links are relative to the root (in other words I'm specifying ~/mylink and not hardcoding the mydomain.com part). Any idea why IIS or asp.net is removing www from all my links?

You could setup another website specifically for the non-www one and force it to redirect back to the www site.
Then setup logs in a different location and see if that lets you find the offending pages/links.
Otherwise you may have to use some link checking script to see if any links are coming out incorrectly. Normally, you should be using '~' in your links so that they get resolved by ASP.NET. This should give you an app relative root which shouldn't give you this error.
So you may have a few 'http...' links in there.
Failing that, I can't think of another reason!
HTH anyway.

Related

IIS 10 web routing configuration

I am not sure how this done or what I need to do, I think all I need is a simple rewrite rule but I do not know.
I have a website that www.mysite.com loads the site, but when I browse to mysite.com it goes to a different page that basically says pageOk. I am not sure where that redirect is happening - as this was occurring with our old server (some one else managed that) - I installed IIS on a new server and so now the traffic at www.mysite.com is fine but I still have this issue of mysite.com showing a page that I do not have in my application.
What do I need to do to fix this or where might this issue be coming from ?
firest check the do any is URL rewrite rule and HTTP redirect is affecting this. check both server level and site level.
try to run failed request tracing in iis.
check browsers developer tool -> network tab which status code it is showing.
https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis

Hidden redirect on IIS site?

We have an ASP.NET webforms web application running on IIS 6. There is a permanent redirect in place, for one of its pages: https://www.deurengigant.nl/content/voorwaarden.htm to https://www.deurengigant.nl/content/voorwaarden.
This redirect isn't happening on our local testing version, nor is it happening on a live test version, using the exact same code (including web.config, which has the database connection string): http://test.deurengigant.nl/content/voorwaarden.htm. (Yes, we don't have https on the test version.)
I've already checked the URL rewrite section in IIS Manager for the web site, but there is nothing there. (Pretty sure it simply shows what's defined in web.config rewrite rules anyway.) The HTTP Redirect section shows nothing either.
I've gone through the code looking for redirects, but couldn't find the problem there; also, the test version and our local version use the same code folder.
I've also checked the URL in a Chrome incognito session, to make sure the permanent redirect isn't pulled from cache.
What could I have overlooked? Where else could the 301 Permanent Redirect be set up?
The redirect is in applicationHost.config, which is located in C:\Windows\System32\inetsrv\config.
I think it's unwise to put it there, since that file is usually not in source control, nor copied to developer machines for local debugging.
As for why the test version on the live server doesn't have the redirect… I still don't know! They both use applicationHost.config, so they should have them both! That said, check the "error pages" section of IIS Manager. For me, it gives an error for the test version, stating: "cannot add duplicate collection entry of type 'error'". This refers to the error nodes in the httpErrors section of web.config and applicationHost.config, so I think it might be related to that. Maybe a nice conundrum for a rainy day.

When I switch to https, my pages return a 404 error in Mono + Apache

I am using Mono + Apache for ASP.Net and when I go to the https version of my site it asks if I want to accept the certificate (I check to save it permanently) but then it shows a 404 error page! None of my pages show up under https. How do I fix this?
(What info do you need me to post to help diagnose this?)
I discovered the problem: Apache had a default "example" virtual host file to handle SSL requests. Even though I'd created my own, that one was taking precedence, so the directory of that virtualhost was being served for SSL.

How can I set the default page for https requests?

We have a website which has a Virtual Directory containing the secure portion of the website.
If users come to http://www.mydomain.com, they should get directed to default.aspx of the main site, but if they go to https://www.mydomain.com, they should go to default.aspx of the virtual directory.
The default page for the main site works fine, as does the secure page if I navigate to it using the full name, however I can't figure out how to set the default page for https traffic that doesn't specify a specific page.
http://www.mydomain.com - Works
https://www.mydomain.com - Page Not Found
https://www.mydomain.com/myvirtualdirectory - Page Not Found
https://www.mydomain.com/myvirtualdirectory/default.aspx - Works
What do I need to do to make links 2 and 3 load the default page show in 4?
My website is running on IIS 6.0 in Windows Server 2003
Overall, this is an anti-pattern as you state the entire behavior of the site changes based on the port. I am not stating definitively you are doing this, but consider the following:
If you are redirecting due to a user needing to see other things, you can make conditional controls that display only when in HTTPS. The same can be done for authenticated and authorized versus not.
If you are redirecting because an HTTP user needs to log in, the more consistent pattern is to have them click a log in button. And, you can force HTTPS at this point without breaking the pattern.
If you really need to redirect for some reason, there are a couple of ways of handling this:
In IIS
HTTP Handlers
URL Rewrite - requires the URL Rewrite bits for IIS 7
I imagine there are some other ways to solve this.
I finally figured out my issue. In my case, it turns out the problem was an old URL Rewrite rule I wasn't aware of that was transferring all https traffic that didn't have a file name specified to index.php, which of course didn't exist.
I found this out by viewing the IIS error logs, which was telling me the 404 was being caused by index.php

redirect domain.com to www.domain.com with dns and iis , ERROR = "The page isn't redirecting properly"

I have a web site with the name of soscharge.com
for redirecting soscharge.com to www.soscharge.com i followed the below link :
asp.net web site -> how redirect domain.com to www.domain.com with dns and iis? (prevent duplicate for seo)
i really confused for checking http redirect check box in iis 7.0(windows server 2008)?
i configured my iis as that link said...
mean made two web sites in iis (with and without www)...
and installed HTTP Redirection...
but when i want to check redirect check box on domain.com the other web site (www.domain.com) redirect check box is checked!
why?
and when i open domain.com or www.domain.com in browser (firefox) i get the below error :
**The page isn't redirecting properly**
Firefox has detected that the server is redirecting the request
for this address in a way that will never complete.
*This problem can sometimes be caused by disabling or refusing to
accept
cookies.
how can i prevent double checking of redirect checkboxes?
is this normal?
and how can i fix that error?(my cookies are enable in FireFox)?
thanks in advance
In IIS 7, if you set the site directory the same in the www and non-www versions you'll run into an infinite redirect situation as IIS actually makes an entry in the web.config file, and since both sites are pointing to the same place they share the same config. I leared this the hard way as well!
Now, I point the redirect site to an empty directory so it can have its own web.config.
If you don't like having a bunch of sites set up just for redirecting, another solution is to use the url rewrite module and make a redirect rule. Here is a blog posting about that: http://blogs.iis.net/carlosag/archive/2010/03/31/seo-made-easy-with-iis-url-rewrite-2-0-seo-templates.aspx

Resources