Nov 12 2008

Fun with htaccess

Category: SoftwareTeknovis @ 17:50

I have now started using pretty URLs for my permalinks. This took me a long time to get working, but I have to admit that this was my own fault :o

Configuring permalinks within WordPress is straight-forward, and it is described in Using Permalinks.

My problems occurred because WordPress could not create the required .htaccess file due to the way that Blacknight has installed WordPress in a different directory to the one that appears in the URL.

In trying to solve my problems, I learned a lot about .htaccess files! I thought that these Stupid htaccess Tricks were very useful.

Everything appears to be working perfectly now, but there is still one thing that I do not understand. My .htaccess file contains the following three lines:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

There are many pages, such as htaccess rewrite code explanation, that describe these three lines. It is the explanation for the third line that confuses me:

Rewrites any request with 1 or more characters to /index.php, which launches wordpress and handles all redirections and what to display.

Firstly, the RewriteRule documentation states that the matched pattern is replaced with the substitution string. Furthermore, the Regular Expression documentation states that the period will match any single character! So what exactly is happening here?

Secondly, how does it rewrite the request to /index.php? Is it appended to the URL, or is it sent as a POST variable?

Tags: , , ,