WordPress permalink tip

For anyone setting up a new self-hosted WordPress blog (not on wordpress.com or any similar hosting service), here’s a tip on getting your permalinks set up and getting rid of the queries in the links.

When you select a permalink pattern from the list of options (default, day and name etc.) and then select “Save changes”, it will tell you that you need to rewrite your .htaccess file. This file tells your web server software (likely Apache) what to do when someone tries to read a file or location that doesn’t exist, such as the fake file paths commonly used in permalinks. When you select the permalink pattern, it will change the contents of the line-edit box next to “Custom structure”. Insert “/index.php” (without the quotes) in front, check the box to the left of “Custom structure” and select “Save changes”. There is no need to alter your .htaccess then.

Why? Because index.php is a real file, and as that exists, the rest of the URL will be passed to it as a query. This saves fiddling around with trying to upload a hidden file which might not show up in your FTP client either on your system or on the web host. It works just as well (maybe even faster) even though it might look a little less clean. The “mt.php” in all my permalinks dates from a time when I was using Movable Type and had a host which wouldn’t let me edit my .htaccess file (for any MT users, mt.php was a renamed mtview.php); now I need it there just to make sure any link to my entries still works.

Possibly Related Posts:


Share