http://tech.einaregilsson.com/2007/07/30/pretty-wordpress-permalinks-on-iis/
<?php
$qs = $_SERVER['QUERY_STRING'];
$pos = strrpos($qs, '://');
$pos = strpos($qs, '/', $pos + 4);
$_SERVER['REQUEST_URI'] = substr($qs, $pos);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include('index.php');
?>
--------------------------------------------------
It’s requirements are:
To install, copy and paste this text into a file named wp-404-handler.php:
<?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ‘:80′)+3);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include(’index.php’);
?>
Next set the 404 error page to /wp-404-handler.php. If it gives you a choice between file and url, choose url.
Lastly, make sure you enable permalinks in the Wordpress control panel under Options > Permalinks.
Subject: How do I set up "Pretty Permalinks" on my WordPress blog? To create a .htaccess file, open up your preferred text editor and enter in the following: Save the file as ".htaccess" and place it in the root of your blog directory via FTP. This can be done at the time of your WordPress install or afterwards. If your text editor appended an extention to your .htaccess file, such as ".txt" or ".html," be sure to remove that. It should only be ".htaccess"
Article #1152
1. Overview: What are permalinks?
Permalinks, in WordPress, are the permanent URL addresses associated with all of your blog posts, categories, pages, etc. The URL for each of your blog posts should be permanent, and never change — hence permalink. By default, your WordPress permalinks are set to "ugly."![]()
The letter "N" in the above example is the Post ID number. As you can see, the URL isn't easy or intuitive, as something like "http://example.com/category/post-title" would be.
Our hosting environment also supports PATHINFO, or "Almost Pretty" permalinks. These types of permalinks are similar to the intuitive structure of "Pretty Permalinks" but for one exception. PATHINFO permalinks have an "/index.php" inserted.![]()
If your hosting plan supports IIS Mod-Rewrite, you can produce much nicer URLs, or "Pretty Permalinks," for your blog posts. Some common structures of Pretty Permalinks would be:![]()
2. How to set up your blog to use "Pretty Permalinks."
There's essentially only three steps to enable Pretty Permallinks on your WordPress blog.
1) Create a .htaccess file with rewrite rules
2) Place the .htaccess file into the root of your blog directory
3) Select the custom permalink structure option in your WordPress Settings# BEGIN WordPress
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
# END WordPress
Please note, if you're familiar with IIS Mod-Rewrite or Apache mod_rewrite, there are a number of different ways to create URL rewrite rules. The above example is just that--an example, and not the only way to accomplish setting up Pretty Permalinks in WordPress. With that said, however, we have tested the above rewrite rules in a .htaccess file in our hosting environment.
The last thing you'll need to do is change the permalink settings in WordPress.
In WordPress version 2.7.2, log in to your WordPress admin portal (i.e. http://yourdomain/blog/wp-admin), and select "Settings" on the very bottom of the Menu options that are on the left-hand side of the screen.
Then select "Permalinks."![]()
Then select the "Custom Structure" option among the different permalink options.![]()
There are many different custom structures you could use, but a commonly used structure would be year/month/day/post name. The structure tag for this, which you would enter in the Custom Structure field, would be: /%year%/%monthnum%/%day%/%postname%/
For more Structure Tags, please visit http://codex.wordpress.org/Using_Permalinks.
Once you've entered in your desired structure tags, click Save Changes. Now all of your blog posts, categories, and pages will be using Pretty Permalinks.
Tags: -
Related entries:
Last update: 2009-12-21 09:15
Author: Administrator
Revision: 1.4