Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

web.config redirect issues

Posted on 2016-11-10
5
Medium Priority
?
79 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 29

Accepted Solution

by:
Dan McFadden earned 2000 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 29

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

824 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