buy tb-500

Custom wordpress permalinks in windows server 2008

Use the following instructions to create pretty permalinks for your blog posts.

To enable pretty permalinks in Word Press:

  1. Log on to WordPress with Administrator user rights.
  2. In WordPress, click the Options tab.
  3. On the Options page, click the Permalinks subtab.
    This will take you to the page where you can customize how WordPress generates permalinks for blog posts.
  4. On the Permalinks page, select Custom, specify below and enter “/%year%/%monthnum%/%day%/%postname%/” in the Custom structure text box.
  5. Click Update Permalink Structure.

All the blog post links will have URLs that follow the format that you have specified, but if you click any one of those links the Web server will return a 404 – File Not Found error. This is because WordPress relies on a URL rewriting capability within the server to rewrite requests that have “pretty permalinks” to an Index.php file. In the next section, you will create a rule that will provide this capability.

Creating a Rewrite Rule

Open the Web.config file that is located in the same directory where the WordPress files are installed, and paste the following XML section into the system.webServer element:

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

This rule will try to match any requested URL. If the URL does not correspond to a file or a folder on the file system, it will rewrite the URL to the Index.php file. At that point, WordPress will determine which content to serve based on the REQUEST_URI server variable that contains the original URL before it was modified by this rule.

Testing the Rewrite Rule

After you save the rewrite rule to the Web.config file, open a Web browser and click any one of the permalinks in your WordPress blog. You should see the correct content returned by the Web server for each permalink.

Summary

In this walkthrough you learned how to use the URL Rewrite module to enable “pretty permalinks” in the WordPress blog engine. WordPress is just one example of the many popular PHP applications that can take advantage of the URL Rewrite module in IIS 7, a feature that enables user-friendly and search engine-friendly URLs.

References

http://learn.iis.net/page.aspx/466/enabling-pretty-permalinks-in-wordpress/

Leave a Reply