Solved

web.config redirect issues

Posted on 2016-11-10
5
22 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 26

Accepted Solution

by:
Dan McFadden earned 500 total points
Comment Utility
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
Comment Utility
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 26

Expert Comment

by:Dan McFadden
Comment Utility
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
Comment Utility
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
Comment Utility
Awesome!!! Thanks!!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Here are the symptoms: You start receiving calls from users that one of your legacy web apps isn't coming up, so you log into your IIS 5 server to check it out.  When you pull up the services, you notice that the WWW Publishing service isn't runn…
Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now