Solved

web.config redirect issues

Posted on 2016-11-10
5
49 Views
Last Modified: 2016-11-12
Hello,
I need to do a 301 permanent redirect for several files on my website.

Here is the original code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <defaultDocument>
            <files>
                <clear />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
        <httpProtocol>
            <customHeaders>
                <clear />
                <add name="X-Powered-By" value="ASP.NET" />
            </customHeaders>
        </httpProtocol>
        <httpErrors>
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" subStatusCode="-1" path="/404.html" responseMode="ExecuteURL" />
        </httpErrors>
  </system.webServer>
</configuration>

Open in new window


For example, I need to redirect any request to http://www.mydomain.com/current.html to http://www.mydomain.com/new.html 
I need to do this for 30 or so pages.

I tried adding in
<location path="current.html">
      <system.webServer>
        <httpRedirect enabled="true" destination="http://mydomain.com/new.html" httpResponseStatus="Permanent" />
      </system.webServer>
    </location>

Open in new window


But all I got was 500 errors.
Help!
0
Comment
Question by:SOTA
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
Dan McFadden earned 500 total points
ID: 41883427
You should check out the URL Rewrite feature in IIS.

Various articles on URL Rewrite:  https://www.iis.net/learn/extensions/url-rewrite-module

In your case, you might want to investigate creating a URL Rewrite map.  This is where you define older pages and map rewrites to the new destination.

Link:  https://www.iis.net/learn/extensions/url-rewrite-module/rule-with-rewrite-map-rule-template

Here is a good article on the various capabilities of the URL Rewrite feature in IIS:  http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/

Dan
0
 

Author Comment

by:SOTA
ID: 41883922
Thanks for that Dan. The issue is my website is a hosted one (Arvixe) and I have no access to IIS and therefore no way to install URL Rewrite, nor any way to run the add-on (that I am aware of).

Russ
0
 
LVL 27

Expert Comment

by:Dan McFadden
ID: 41884782
What type of hosting package do you have with them?  Personal or Business Class with Windows?  Either way according to their website the URL Rewrite module for IIS7 is already installed and available.

Here is their site showing the Personal Class offerings... the Business Class is similar.  Look under the "Development" section:

https://www.arvixe.com/asp_net_web_hosting

Dan
0
 

Author Comment

by:SOTA
ID: 41884785
Thanks very much Dan!
I finally got it to work.
I inserted LOCATION between CONFIGURATION and it seems to be working now:

  <location path="aboutus.html">
    <system.webServer>
      <httpRedirect enabled="true" destination="/about-sharing-health.html" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>

Open in new window

0
 

Author Closing Comment

by:SOTA
ID: 41884786
Awesome!!! Thanks!!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question