IIS7 webpage redirect question

IIS7 webpage redirect question - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the IIS7 webpage redirect question error on your web browser. Problem :


Noob question here. I searched, but couldn't quite find anything that would explain how to do this. I'm using IIS7 on a 2 server web farm with traffic being load balanced to either of the two servers.



I have a URL http://something./org that goes to page http://something.mydomain.com



On this page there is a hyperlink that users can click on that will take them to http://something.mydomain.com/search.



I would like to redirect users that go to http://somethingsearch.org/ to redirect them to http://something.mydomain.com/search



Is this possible? I'm thinking an ISAPI Rewrite Rule might be necessary to accomplish this, but I'm unsure.



Sorry if there's not enough information provided. I was just thrown this little task earlier today and they're looking for a quick turnaround. If there are any questions or any other information that you might need, let me know and I'll see if I can dig it up.


Solution :

You can use the IIS URL Rewrite extension from Microsoft.




IIS URL Rewrite 2.0 enables Web administrators to create powerful rules to implement URLs that are easier for users to remember and easier for search engines to find. By using rule templates, rewrite maps, .NET providers, and other functionality integrated into IIS Manager, Web administrators can easily set up rules to define URL rewriting behavior based on HTTP headers, HTTP response or request headers, IIS server variables, and even complex programmatic rules. In addition, Web administrators can perform redirects, send custom responses, or stop HTTP requests based on the logic expressed in the rewrite rules.




IIS URL Rewrite is the equivalent of apache mod_rewrite for IIS.



I have a rewrite rule that forces my site url to be prefixed with "http://www". This is mainly for google analytics. So if someone goes to http://mywebsite.com it will redirect them to http://www.mywebsite.com.



You can accomplish this in two ways:




  • Create the rewrite in IIS if you have IIS URL Rewrite installed. Here is how it is done:



Add a rewrite rule in IIS Manager




Match URL Section




  • Name the rule

  • Select "Matches the Pattern" under Requested URL:

  • Select "Regular Expressions" under Using:

  • Add this expression "^(.*)$"

  • Check "Ignore case"



    Match URL Section Screen Shot







Conditions Section




  • Set "Logical grouping" to "Match All"

  • Click the "Add" button

  • Enter "HTTP_HOST" for the Condition input

  • Select whether or not you want it to match the pattern (in my case I did not)

  • Enter the expression "^www.(.+)$"

  • Check "Ignore case"



    Add Condition







Action Section




  • Select "Redirect" for the Action type

  • Enter your redirect URL - in my case it was: "http://www.HTTP_HOST/R:1"

  • Check "Append query string"

  • Select "Permanent (301)" as the redirect type



enter image description here



Save the rule





  • If the site is a .NET site, edit the web.config to add the rule under the "system.webServer" section



    <rewrite>
    <rules>
    <rule name="wwwrewrite" enabled="true" stopProcessing="true">
    <match url="^(.*)$" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="HTTP_HOST" pattern="^www.(.+)$" negate="true" />
    </conditions>
    <action type="Redirect" url="http://www.HTTP_HOST/R:1" appendQueryString="true" redirectType="Permanent" />
    </rule>
    </rules>
    </rewrite>



Hope this helps....



My co-worker that took this over was able to come up with a solution that worked for us on this one. Just figured I'd post to close the loop on this one so if anyone else runs into a similar issue, it might help them out as well.



He wrote an ISAPI ReWrite/ReDirect rule using the ISAPI ReWrite Manager for ISS that looks like this:



RewriteEngine on

RewriteCond %HTTP_HOST ^(www.)?domain.org$

RewriteRule ^(.*)$ http://something.domain.com/Search [I,O,RP,L]


This is very much in line with what you folks were saying, but the issue he ran into was with trying to maintain the same URL http://something.org while redirecting to a subdirectory within the site.



So, he just said to hell with it and redirected to a different URL with the sub-directory included.



Thanks all for your input!!


We hope that this article has helped you resolve the redirects, url-rewriting, iis7 error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=