Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:Lazyking/Using Permalinks (Saetta Web Server)

To use Permalinks with Saetta Web Server a properly configured URL rewriting module written in the C programming language is required.

  1. Download the module
  2. Configure the module
  3. Build the module
  4. Add the URL rewriting module to the server software
  5. Restart the web server or reload its configuration
  6. Patch WordPress
  7. Configure WordPress

Download the module

Direct download link to the source code of the module.

Configure the module

Optionally edit the file wordpress.c to change the default paths.

Search for the WORDPRESS_SHARED define:

#define WORDPRESS_SHARED "/wordpress/"

Replace the path /wordpress/ with the path you use to access WordPress. For example, if you access WordPress from http://website.de/blog/wordpress/ you've to set WORDPRESS_SHARED to "/blog/wordpress/". It's important for the value of this variable to begin and to end with a slash (“/”).

By default the URL rewriting module will automatically discover the right DOCUMENT_ROOT variable of the virtual directory matching the rewriting rule. You can improve a bit the performance of the URL rewriting module by defining the VDIR_DOCUMENT_ROOT variable manually:

// This variable doesn't want a slash at the end of its value. #define VDIR_DOCUMENT_ROOT "/var/www"

Full example:

  • Wordpress is installed at http://website.de/blog/wordpress/
  • The path to the real files on your server is: /var/www/blog/wordpress/
  • The virtual directory is specified in the XML configuration file of your website as: <directory www="/" root="/var/www" >

Then you've to set:

#define WORDPRESS_SHARED "/blog/wordpress/" #define VDIR_DOCUMENT_ROOT "/var/www"

(concatenating VDIR_DOCUMENT_ROOT and WORDPRESS_SHARED results in the full server path to the files)

Build the module

Build the module using the GNU C compiler:

gcc -Wall -shared -O3 -s -fPIC -pthread -o wordpress.so wordpress.c

Add the URL rewriting module to the server software

Upload the module to the server if compiled off site, and then add it to the XML configuration file of your server: <websites> <website host=":80"> <urlrewriters> <urlrewriter enabled="1" path="/var/www/private/wordpress.so" entrypoint="saetta_main" /> </urlrewriters> .... </website> </websites> Set as path the full path to the compiled module.

Restart the web server

Start or restart the web server.

Patch WordPress

Open the wp-includes/vars.php file. Look for:

$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false ...);

and replace that line with:

$is_apache = true;

Open the wp-includes/load.php file. And, in the function function wp_fix_server_vars(), insert after

$_SERVER = array_merge( $default_server_values, $_SERVER );

this code: if(php_sapi_name() == 'saetta' && isset($_GET['X-ORIGINAL-URL'])) $_SERVER['REQUEST_URI'] = $_GET['X-ORIGINAL-URL'];

Configure WordPress

Configure WordPress from the WordPress Admin panel to use the Permalinks you prefers.

  • That's all