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?