KeyFocus - KFWS Support
 
 
 

KF Web Server Frequently Asked Questions

Application Questions

  • How do I configure WordPress permalinks to work?




  • Questions & Answers


    CGI Questions


    How do I configure WordPress permalinks to work?

    WordPress is a state of the art free Blogging application.

    Wordpress contains a feature called permalinks which make the URL both user and search engine friendly.
    For example, the page for February 2006 by default is:
    http://www.mydomain.com/index.html?m=200602
    and with permalinks it becomes
    http://www.mydomain.com/2006/02/

    In order to get this working under KF Web Server various configurations need to be changed and this is described below.

    Wordpress is based on PHP and MySQL and you will first have to install both of these systems and get them running.

    Download the WordPress source code as a zip file from http://wordpress.org/.
    Uncompress the zip file and read the installation instructions in readme.html.
    This involves copying the files to your web sites document root directory and setting up the MySQL database.

    Once you are happy that WordPress is working you can then proceed with the following configuration changes to make permalinks work.

    1. In order for this to work PHP needs to enable the PATH_INFO CGI feature, which is not enabled by default in php.exe.

      If you are using "php-cgi.exe" to run PHP then you do not need to make this change.

      Using a text editor, such as Notepad, edit the php.ini file, usually found in C:\Windows.
      Add the following line to the file:
      cgi.fix_pathinfo=1
    2. WordPress is designed to use Apache Rewrite module and will only recognise KF Web Server if it is reconfigured.
      Using a text editor, such as Notepad, edit the file /wp-admin/admin-functions.html.
      Find the text function got_mod_rewrite(). Comment out the line of code that return false by using a #.

      So the function should look like:
      function got_mod_rewrite() {
      global $is_apache;

      // take 3 educated guesses as to whether or not mod_rewrite is available
      # if ( !$is_apache )
      # return false;

      # if ( function_exists('apache_get_modules') ) {
      # if ( !in_array('mod_rewrite', apache_get_modules()) )
      # return false;
      # }

      return true;
      }

      Save the file.

    3. In the KF Web Server Admin page go to the Server -> General menu.

      Tick the checkbox Accept Path Info and press OK.
      This enables the use of virtual directories as parameters to scripts.

    4. In the Web Sites menu, edit the web site containing WordPress and go to the URL-Rewrite-Rules sub menu.
      Add the following rules, by pressing the Add button.

      Rule 1:
      Pattern: ^/([0-9]+)?/
      Substitution: /index.html/$1/

      Rule 2:
      Pattern: ^/(about|category)/
      Substitution: /index.html/$1/

      If you add more custom pages to WordPress you will need to add them to this rule.
      For example if you add a page called booklist then change the pattern to ^/(about|category|booklist)/

      Don't forget to press the Save And Restart button.

    5. You are now ready to enable permalinks in the WordPress system.
      Once logged on to WordPress as admin, go to the Options -> Permalinks menu. Select one of the options, such as Date and name based.

      The permalink option in the Custom structure: should appear as:
          /%year%/%monthnum%/%day%/%postname%/
      and not as
          /index.html/%year%/%monthnum%/%day%/%postname%/

      If index.html appears then it means WordPress does not think it has mod_rewrite available.
      This should have been fixed by editing function got_mod_rewrite in step 2.

      If you cannot fix this then you will need to change the KF Web Server rewrite rules to include index.html
      e.g. change the pattern in this way:
      Pattern: ^/index.html/([0-9]+)?/

      Press the Update Permalink Structure button.

    6. These instructions assume you have installed WordPress into the web site root directory. There is documentation in WordPress on how to insall it in a sub-directory. If you do this you will need to change the KF Web Server rules to include this sub-directory.
    7. There may be a problem when running certain plugins. An error message like this may be reported:
      Fatal error: Cannot redeclare class wpdbbackup in /blablabla/wp-content/plugins/wp-db-backup.html on line 26.

      This seems to be a problem with WordPress and there is a discussion on their site: http://wordpress.org/support/topic/52702