Solved

web.config redirect issues

Posted on 2016-11-10
5
64 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 28

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 28

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

626 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