Jump to content



Photo

301 Redirect Question

html

  • Please log in to reply
5 replies to this topic

#1 M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 03 July 2013 - 18:24

Hi everyone.

 

I am trying to do a 301 Redirect and each time I attempt to do so I somehow mess it up and make the site unavailable...

 

So, I wanted to ask on here what I'm doing wrong and how I can do this.  I have a web.config in my site directory and everything else seems to work (I have it redirecting to an error page if the page isn't found, etc.).

 

But the 301 I've had a lot of issue with.

 

Here is my web.config:

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
            <rule name="www redirect" enabled="true" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^[^\.]+\.[^\.]+$" />
        <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" />
</rule>
<rule name="www redirect https" enabled="true" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^[^\.]+\.[^\.]+$" />
        <add input="{HTTPS}" pattern="on" />
    </conditions>
    <action type="Redirect" url="https://www.{HTTP_HOST}/{R:0}" />
</rule>
        <defaultDocument enabled="true">
            <files>
                <clear />
                <add value="index.aspx" />
                <add value="index.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="home.aspx" />
                <add value="home.asp" />
                <add value="home.htm" />
                <add value="home.html" />
                <add value="default.aspx" />
                <add value="default.asp" />
                <add value="default.htm" />
                <add value="default.html" />
            </files>
        </defaultDocument>
        <httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/moved.html" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

 

So, what do I put where?  lol  I REALLY appreciate the help.

-Matt-




#2 +Seahorsepip

Seahorsepip

    http://seapip.com

  • Tech Issues Solved: 23
  • Joined: 23-January 11
  • Location: Netherlands
  • OS: Windows 8.1 Pro
  • Phone: Nexus 5

Posted 05 July 2013 - 12:26

Why not use .htacces?



#3 OP M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 08 July 2013 - 14:53

Why not use .htacces?

It's a Windows Hosting, so my understanding was that I had to use a web.config file...

 

Sorry, I should have mentioned that.



#4 +Seahorsepip

Seahorsepip

    http://seapip.com

  • Tech Issues Solved: 23
  • Joined: 23-January 11
  • Location: Netherlands
  • OS: Windows 8.1 Pro
  • Phone: Nexus 5

Posted 08 July 2013 - 15:30

            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/moved.html" responseMode="ExecuteURL" />
            <remove statusCode="301" subStatusCode="-1" />
            <error statusCode="301" prefixLanguageFilePath="" path="/moved.html" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

Above code at the end will do I think, never really used windows servers that much but it looks like the most obvious :p 



#5 OP M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 15 July 2013 - 20:08

Thanks, let me try that and I will post back.  I really appreciate the help.  Every time I try to do this I inadvertently take the whole website down...  :|



#6 OP M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 17 July 2013 - 17:28

Alright, I tried that, and it didn't seem to work.  I have searched online a ton but have not been able to find a solution that worked either...

 

I tried reworking the suggestion like so: 

 

            <remove statusCode="301" subStatusCode="-1" />
            <error statusCode="301" prefixLanguageFilePath="mysite.com" path="www.mysite.com" responseMode="ExecuteURL" />
 
But that didn't work either...
 
Does anyone have any ideas?  I really don't know what I'm doing wrong here...
 
Thanks Again for the help.