views:

6400

answers:

12

I'm trying to get URL rewriting to work under IIS 7 at GoDaddy. I have wordpress installed and would like to use the "pretty" permalinks.

After searching I found a few articles at learn.iis.net (general info and specific info for wordpress) but nothing from those articles helped me.

I tried adding a web.config with the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Main Rule" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

An error 500 appears if I use this web.config, it doesn't recognize the rewrite tag. So I tried contacting GoDaddy support and they replied with this message:

You would be able to perform URL rewriting however we would be unable to provide technical support on how to accomplish this. I apologize for any inconvenience.

So they do support URL rewriting but they do not want to tell us how.

Anyone had this problem and managed to fix it?


Update from GoDaddy

Thank you for contacting Online Support. I apologize for the confusion. While you are able to use URL rewriting with any of our Windows hosting accounts we are unable to provide support on this. That being said if we do not provide support on a specific subject there are not going to see any help articles related to this within our help center since we cannot support it. You will need to use a search engine or community forum for assistance with setting up URL rewriting with your account. I apologize for any inconvenience this may cause.

Looks like I either find the solution here or use a Linux hosting account (which I'd rather not).

A: 

Are you sure that GoDaddy has the IIS URL Rewrite module installed?

alex
It doesn't seem to have that particular module (since I'm getting the error 500 page), but it says that it supports URL rewriting, maybe through ASP.Net or with another module.
GoodEnough
yeah, you could do your own URL rewriting without that particular module, so perhaps that's what it means. But the rule you're trying to use is dependent on the module.
alex
+4  A: 

I have a friend at GoDaddy who said that they are planning to support the Microsoft Url Rewriter soon, but it's not currently installed. For now, I'm using the ManagedFusion Url Rewriter on my blog which is hosted at GoDaddy.

If you want details on how I have it setup, check out my blog post, or another stackoverflow question I answered.

Rob Boek
I found your post after a while, I tried it but it kept giving me the error 500. I went with a Linux hosting account which I'll upgrade to Windows once they support the Microsoft Url Rewriter. Thanks
GoodEnough
A: 

I'm having exactly the same problem. As soon as I include the <rewrite> tag in the <system.webService> element I'm getting type 500 errors.

I'm trying to use this with MediaWiki. The domain hockeywiki.org is installed pointing at a subdirectory from my hosting account. The web.config file is in the root of that subdirectory, and MediaWiki is installed in the /w folder.

Strangely, GoDaddy tech support pointed me to URL Rewriter for IIS documentation. Is there some other tag that needs to be added to enable Rewriter processing? Or does the <rewrite> element signal it to run?

A: 

Latest update from GoDaddy support...

Windows hosting accounts that are running IIS7 do support the URL Rewrite Module by default. Unfortunately we would be unable to provide further assistance on this issue as we do not provide scripting support. For further information you can view Microsoft’s® URL Rewrite Module documentation.

Please let us know if we can assist you in any other way.

And now I'm completely confused. The web.config file won't accept the <rewrite> tag, and according to GoDaddy it should be enabled and functioning properly.

A: 

is there anyway to ask godaddy to Install URL rewritter module given by Microsoft ? if they are not giving support on this issue, then how one can move to godaddy ?

+5  A: 

Just an update to this question. As of today, I am able to get the URL Rewrite Module in IIS7 to work at godaddy. I have an "Economy Hosting - Windows" account with Godaddy.

I uploaded a very simple web.config to my site's root directory (called "html" in my case), and redirect is working correctly for me. Here's my simple test web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
     <rewrite>
      <rewriteMaps>
       <rewriteMap name="StaticRedirects">
        <add key="/oldfilename.jpg" value="/newfilename.jpg" />
       </rewriteMap>
      </rewriteMaps>
      <rules>
       <rule name="RedirectRule" stopProcessing="true">
        <match url=".*" />
        <conditions>
         <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
        </conditions>
        <action type="Redirect" url="http://www.mydomain.com{C:1}" appendQueryString="False" redirectType="Permanent" />
       </rule>
      </rules>
     </rewrite>
    </system.webServer>
</configuration>

When I try to visit http://www.mydomain.com/oldfilename.jpg, my browser is successfully redirected to http://www.mydomain.com/newfilename.jpg .

Tex
Anyone can confirm this?
GoodEnough
This worked for me. I think the mistake I made was that I didn't originally put the <rewrite> node under <system.webServer>. I haven't tested my original since I was able to modify this sample to make it work. Thanks. +1
Steve Hiner
Now I just have to figure out how to get it to grab the entire query string and slap it on the end of the new url. Just using appendQueryString="True" does not appear to be sufficient - I get a 404 for URLs with query strings.
Steve Hiner
+1  A: 

As odd as this may sound, I think URL Rewrite works on Windows Economy Hosting with IIS7, but not on Windows Deluxe Hosting accounts (with IIS7). I've got one of each hosting account, and I was able to get URL Rewrite to work perfectly on the Economy Hosting account but doesn't work at all on the Deluxe account. I found that if I included even the tag I would start getting 500 errors and I couldn't find any variation that worked.

When I contacted Godaddy, they said that there was an error in my config file, but couldn't explain why the configuration that worked on Windows Economy account (any on my local IIS7 server), but not on the Windows Deluxe account. They went as far to say that the configuration may vary slightly between their servers, but URL Rewrite should be on all of them. I don't believe them.

At any rate, here's the file that I got to work on my Economy account if this can help anyone:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <identity impersonate="false" /> 
  </system.web>
  <system.webServer>
    <rewrite>
      <rules>
     <rule name="Move posts to blog" stopProcessing="true">
       <match url="^post(.*)" ignoreCase="true" />
       <action type="Redirect" url="/blog/{R:0}" appendQueryString="false" redirectType="Permanent" />
     </rule>
     <rule name="Move images to blog" stopProcessing="true">
      <match url="^image.axd(.*)" />
      <action type="Redirect" url="/blog/{R:0}" appendQueryString="true" />
     </rule>
     <rule name="Move files to blog" stopProcessing="true">
      <match url="^file.axd(.*)" />
      <action type="Redirect" url="/blog/{R:0}" appendQueryString="true" />
     </rule>  
     <rule name="Move pic to blog" stopProcessing="true">
      <match url="^pics/(.*)" />
      <action type="Redirect" url="/blog/{R:0}" appendQueryString="false" />
     </rule>
     <rule name="Move root to blog" stopProcessing="true">
      <match url="^$" />
      <action type="Redirect" url="/blog/" appendQueryString="false" redirectType="Permanent" />
     </rule>
     <rule name="Canonicalize blog" stopProcessing="true">
      <match url="^blog$" />
      <action type="Redirect" url="/blog/" appendQueryString="false" redirectType="Permanent" />
     </rule>
      <rule name="Canonicalize default filename" stopProcessing="true">
        <match url="(.*)default.aspx$" />
        <action type="Redirect" url="{R:1}" appendQueryString="false" redirectType="Permanent" />
      </rule>
    </rules>
    </rewrite>
    <defaultDocument>
     <files>
      <clear />
      <add value="default.aspx" />
     </files>
    </defaultDocument>
    <directoryBrowse enabled="false" />
  </system.webServer>
</configuration>
nathan buggia
A: 

I had the same problem, and I have just sovled it. I created web.config with VS 2008, when I upload the web.config file, a 500 error turned out. After I deleted [encoding="UTF-8"] in the web.config file, it works great! This is my blog www.tzingchu.com on GoDaddy's win shared hosting.

Tzing Chu
+1  A: 

Just a note to others who may be having trouble. Make sure to have

<modules runAllManagedModulesForAllRequests="true">

in your web.config

adinas
A: 

There are work arounds to maake URL re-writing work on GoDaddy. I did a work around using 404 FileNotFound and HttpContext.Current.RewritePath(rewritePage) technique for my website.

maniche
A: 

I was searching on here for a similar issue with multiple godaddy wordpress blogs running under one main hosting account with IIS7, each with it's own domain name. The issue was the trailing slash, "/blog" vs "/blog/", since godaddy treats "/blog" as a file and then triggers the 404.

I put a web.config file in the hosting root folder with maps for each blog and it seemed to do the trick.

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rewriteMaps>
                <rewriteMap name="StaticRedirects">
                    <add key="/domainpath1/blog" value="/blog/" />
                    <add key="/domainpath2/blog" value="/blog/" />
                    <add key="/domainpath3/blog" value="/blog/" />
                    <add key="/domainpath4/blog" value="/blog/" />
                    <add key="/domainpath5/blog" value="/blog/" />
                </rewriteMap>
            </rewriteMaps>
            <rules>
                <rule name="RedirectRule">
                    <match url=".*" />
                    <conditions>
                        <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="{C:1}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
Ryan Oblander
A: 

Hello, I am new to the windows web server and have not the knowledge of syntax for web.config file.

We have under Windows IIS7 an Wordpress installation and for that wordpres generated few lines for a web.config file. Here is the content of the web.config file:

  1. with this content our /stats directory and Webstats is no more accessible - we are getting an error 500. In the stats directory is dynamically generated the reports and an index.php file is in this directory which points to the other files in the directory.

  2. we need more rules to create some permanent redirect 301 for the following subfiles:

domain.com/article-details.php --------->>>>> domain.com and domain.com/content.php --------->>>>> domain.com

This two points we need some help.

If I use one of the examples above - I am getting an error 500.

The web.config file from wordpress is working, but our /stats directory is no more accessible - we get an error 500.

So has anyone an idea how to change the rules that the /stats directory is accessible? And if possible, how to add other rules to setup few permanent redirects?

Christian Gnoth
I suggest you post your question in a separate question, you'll get more attention and answers.
GoodEnough