Tag Archive | "Wordpress permalinks"


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"?>
        <rule name="wordpress" patternSyntax="Wildcard">
          <match url="*"/>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
          <action type="Rewrite" url="index.php"/>

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:

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



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:

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



As you see, it’s pretty easy :)


Posted in Windows-IIS-ASPNET, WordpressComments (0)


WordPress Permalinks Configuration

It’s reasonable for your to make your website links/urls clean for SEO consideration, wordpress provided the great ideas from admin panel. If you’re using Apache web server, you don’t need it, you can simply define it directly from your wordpress admin page > settings > permalinks. This solution is for IIS, you need to define custom 404 error pages(including 404, 404,2 and 404,3). Put the following to a file called 404.php under your wordpress maine working directory:

// This is the default file for the site. Usually index.php
$default = ‘index.php’;

// The name of this file.
// Set this value for the URL in Custom Error Properties of your website in IIS.
// Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >
// 404 & 404;2 & 404;3 > URL (Requires a ‘/’ prefix in IIS).
$thisfile = ‘404.php‘;

$_SERVER['ORIG_PATH_TRANSLATED'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_TRANSLATED']);
$_SERVER['SCRIPT_FILENAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_FILENAME']);
$_SERVER['ORIG_PATH_INFO'] = str_replace($thisfile, $default, $_SERVER['ORIG_PATH_INFO']);
$_SERVER['SCRIPT_NAME'] = str_replace($thisfile, $default, $_SERVER['SCRIPT_NAME']);
$_SERVER['PHP_SELF'] = str_replace($thisfile, $default, $_SERVER['PHP_SELF']);
$_SERVER['PATH_INFO'] = false;

$pos = strrpos($qs, ‘://’);
$pos = strpos($qs, ‘/’, $pos + 4);
$_SERVER['URL'] = $ru = substr($qs, $pos);
$qs = trim(stristr($ru, ‘?’), ‘?’);

// Required for WordPress 2.8+

// Fix GET vars
foreach ( $_GET as $var => $val ) {
  if ( substr($var, 0, 3) == ’404′) {
    if ( strstr($var, ‘?’) ) {
      $newvar = substr($var, strpos($var, ‘?’) + 1);
      $_GET[$newvar] = $val;

Now you’ll be able to configure the permalinks in the way you liked.


Posted in WordpressComments (14)