How Do You Configure Windows Azure For Url Rewrite Using WordPress?

I have just created a website using Windows Azure and their template for a WordPress blog. I was able to update the CNAME and Alias records to properly forward my domain to their website. When I go to: www.myblog.net, I am redirected to: myblog.azurewebsites.net and the browser shows www.myblog.net, which is what I want.

This all works fine. The site loads fine and all is well.

Read More

The problem, though, comes when I try to get to a page with a permalink. Through WordPress configuration, I updated my permalinks to be in this format: http://www.myblog.net/blog/The-Post-Name-Is-Here. The problem with this is that when I attempt to go to that URL, I get this error:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

If I go to the shortlink for that same topic (e.g. http://www.myblog.net/?p=241), the page is found and all is well.

I have researched this quite a lot and have found that there is a url rewrite for apache, but that obviously won’t work for me. I have also found that there is a url rewrite for IIS and I have played with this locally. You can configure this to properly manage the url rewrite. However, there is no such IIS panel in the Windows Azure Websites configuration portal.

I have also read a lot about editing web.config and htaccess, but neither of these files are in my wwwroot directory (or any child directories) for my website on azure.

So, does anyone know how to configure azure websites to manage permalinks properly?

Thanks in advance for your help!

Related posts

Leave a Reply

2 comments

  1. WordPress on Windows Azure Websites runs under Microsoft Internet Information Services (IIS), not Apache. IIS also supports URL rewriting but the configuration is done in a Web.config file, not in a .htaccess file.

    First, in WordPress settings, change the permalink to a custom structure without “index.php”, such as:

    /%year%/%monthnum%/%day%/%postname%/
    

    Also make sure in WordPress Settings, General Settings section, the WordPress Address (URL) and Site Address (URL) are correct.

    Next, using FTP, WebMatrix or other tool, create a Web.config file in your WordPress site’s root directory:

    <?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>
    

    For a step-by-step tutorial refer to Pretty WordPress Permalinks on Azure. For additional information refer to Moving a WordPress Blog to Windows Azure – Part 4: Pretty Permalinks and URL Rewrite rules.