Solved

web.config redirect issues

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

24 Experts available now in Live!

Get 1:1 Help Now