0

I've seen a few posts about redirecting domains on GoDaddy, but nothing about single files.

In my case I am using a Windows shared host, so I can't use any IIS management tools. What I'm hoping is that I can do something equivalent to Apache's .htaccess file to configure redirects for single files.

Alternatively, is there an HTML document I can return that performs the same function as an HTTP 301 redirect?

I should point out that I am using plain HTML served from the disk, so I cannot return a custom HTTP response code as I might be able to with say PHP, ASP.NET, ASP, etc.

GoDaddy's documentation does not cover this situation.


EDIT

So user78940's answer shows a viable technique (GoDaddy support <rewrite> in Web.config), however despite reading a few different tutorials on this config element I'm still having trouble getting it to work.

Firstly, I'm using virtual hosting which means I have this physical folder structure:

root                      < -- used for primarysite.com
    - drewnoakes.com      < -- nested virtual hosting
    - someothersite.com   < -- nested virtual hosting

There are three websites here. The root is for primarysite.com, the subdirs are for the correspondingly named sites. This is just how you have to do it with GoDaddy unfortunately. You always have one primary then nest sites there.

Unfortunately the GoDaddy setup gives a redirect if you don't put a trailing slash on a URL (to access the default document of that folder) which means:

http://drewnoakes.com/code/exif (no trailing slash)

...gets redirected to...

http://drewnoakes.com/drewnoakes.com/code/exif/ (with trailing slash)

This means that Google has both URLs in its index. I want to tidy this situation up, making the former redirect properly and the latter redirect to the canonical form so that I don't suffer page-rank dilution and my URLs are less embarrassing easier to remember.

I tried this config, but it ended up with an infinite 301-redirect loop:

<rewrite>
  <rewriteMaps>
    <rewriteMap name="StaticRedirects">
      <add key="/drewnoakes.com/code/exif/" value="/code/exif/" />
    </rewriteMap>
  </rewriteMaps>
  <rules>
    <rule name="RedirectRule" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
      </conditions>
      <action type="Redirect" url="{C:1}" appendQueryString="False" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

So, how can I configure IIS wildcard redirects for this scenario using the <rewrite> configuration element?

Drew Noakes
  • 157
  • 2
  • 13

3 Answers3

1

The <meta HTTP-EQUIV="REFRESH"....> method will return a 200 response (not a true redirect response like 301/302/etc.).

Afaik Go Daddy has no feature in their control panel for redirecting only certain files on shared Windows accounts.

On a shared Windows plan you may be able to use IIS 7 URL rewriting via a web.config file put in the root of your website directory. You would have to confirm that your particular hosting account is on a IIS 7+ server. If so, add the following web.config file to perform a simple redirect:

    <?xml version="1.0"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rewriteMaps>
                <rewriteMap name="StaticRedirects">
                    <add key="/somedir/old-page.html" value="/otherdir/new-page.html" />
                </rewriteMap>
            </rewriteMaps>
            <rules>
                <rule name="RedirectRule" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="http://www.somedomain.com{C:1}" appendQueryString="False" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

For more details you can see the "Using rewrite maps for redirection" section here: http://learn.iis.net/page.aspx/469/using-rewrite-maps-in-url-rewrite-module/

user78940
  • 473
  • 2
  • 7
  • This looks quite promising indeed! I'll give it a shot and get back. Thank you. – Drew Noakes Apr 24 '11 at 16:09
  • So I had a chance to test this out and it looks promising. For simple redirects (ie. fixed URLs) I found the `httpRedirect` element simpler (see the answer I posted [here(http://serverfault.com/questions/262575/how-to-301-redirect-a-single-file-or-directory-on-a-godaddy-shared-windows-hostin/265513#265513)]) but this looks good for wildcard matching. I am still a bit stumped (getting redirect loops) so have updated my question. Would you mind taking another look? Thanks again. – Drew Noakes May 02 '11 at 16:31
  • Just a little bump on this post to let you know that I've put a bounty on it. Have you had a chance to consider my comment above? – Drew Noakes May 07 '11 at 17:17
0

You can do this with a html redirect:

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.somedomain.com/somefile.pl">
n8whnp
  • 1,316
  • 7
  • 9
  • Is that really equivalent to a HTTP 301 response though? Will Google and other search engines update their references to the page? – Drew Noakes Apr 22 '11 at 17:43
  • @Drew I think google/yahoo treat it as a 301 if you do a no-delay "0" refresh. Still looking for a source – iainlbc May 04 '11 at 16:28
  • Hmm. not really clear. Google seems to officially recommend a 301 over a meta refresh. http://www.google.com/support/webmasters/bin/answer.py?answer=79812 Most posts/forums on the topic are very dated (2007/08). Cheers – iainlbc May 04 '11 at 16:33
  • Not to mention that a meta-refresh causes quite a bit of flicker in the browser compared to a 301. Even if a meta updates a search engine's index, but it won't patch people who've hard coded the old URL elsewhere on the web. Those who follow such links will see this flicker. – Drew Noakes May 04 '11 at 16:38
0

Another Web.config approach (which works with GoDaddy shared hosting on Windows too) is to use the httpRedirect config element:

<?xml version="1.0"?>
<configuration>
  <system.webServer>
    <httpRedirect enabled="true" exactDestination="true"
                  httpResponseStatus="Permanent">
      <add wildcard="*from/path" destination="/to/path/" />
    </httpRedirect>    
  </system.webServer>
</configuration>
Drew Noakes
  • 157
  • 2
  • 13