WordPress Permalinks On Windows

As we discussed on this wordpress permalinks configuration there’re several methods to configure friendly URLs for wordpress site. Here’re some issues I would like to discuss.

On windows server 2008 with URL rewrite mode configured environment, you can enable permalinks the same as you did from linux server and it will auto generate the URL rewrite rules from web.config in your website root. The content is the following:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
      <rules>
        <rule name="wordpress" patternSyntax="Wildcard">
          <match url="*"/>
          <conditions>
            <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>

However, if you installed wordpress on both website root and a subfolder of your website and would like to enable permalinks for both, it will give your 500 error about web.config configurations. Here you need to edit the web.config in the subfolder and add "<remove name="wordpress"/>" behind the <rules>

Now the permalinks would be working like a charm!

Sometimes you would like to redirect the 404 error pages to your home page or any other page on your website to avoid negative effect on search engine. you can do as steps below

Locate to your wordpress theme folder and create a 404.php page and paste into the following:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo(‘url’));

exit();

?>

Now, whenever you browse some non-exist pages on your wordpress site, it will be redirected to your website home, you can also specify where you like the page be redirected to from the second line, for example I would like to redirect to google.com, then you can edit like this:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.google.com");

exit();

?>

As you see, it’s pretty easy :)

Share

- has written 121 posts.


Leave a Reply

You must be logged in to post a comment.