Configuring "Clean URLs"

By default your site's URLs will look like this


If you enable "Clean URLs" they can look like this instead


Clean URLs look like "paths" to your pages rather than ?parameter=value server requests (which is what they are).

TL;DR: You can enable Clean URLs by following the PmWiki CleanURLs recipe.

Do It Early or Don't Do It

If you want your content to be discoverable you probably want to get your URLs sorted out early. The reason is because when you make the change every one of your pages will "disappear" from one URL and "reappear" at another.

One PmWiki site that comes to mind is the TV Tropes site that has URLS with "pmwiki.php/" in the path. Here's one of their URLs:

I assume the site owner leaves the path that way because it's not a good idea to break established links.

Changing URLs of established pages has been considered bad practice for decades. Here's a 1998 reference from the inventor of the web himself, Tim Berners-Lee:

It's Not That Hard

Configuring Clean URLs seems intimidating because you need to create a .htaccess file with just the right configuration directives in it. Fortunately you don't need to completely understand the exact meaning of the directives. Once you get it working, it will Just Work.

Visit the PmWiki CleanURLs recipe page and give it a try.

How It's Done Here

For what it's worth, has this in its .htaccess file, located in the docroot (web document root) directory.

# Use mod_rewrite to enable "Clean URLs" for a PmWiki installation.
RewriteEngine On
# The rewrite base will be the document root.
RewriteBase /
# Send requests without parameters to pmwiki.php.
RewriteRule ^$           /site/pmwiki.php  [L]
# Send requests for index.php to pmwiki.php .
RewriteRule ^index\.php$ /site/pmwiki.php  [L]
# Send requests to pmwiki.php, appending the query string part.
RewriteRule ^([A-Z0-9\xa0-\xff].*)$ /site/pmwiki.php?n=$1  [QSA,L]

The matching config.php entries are

 $ScriptUrl = "";
 $EnablePathInfo = 1;
Page last modified on May 17, 2017, at 06:02 PM
Powered by: PmWiki and Quick Wiki CMS