XAMMPLite Virtual Directory And WordPress Permalinks
February 22nd, 2009 by Stephen Cronin (Please wait) [Shortlink]When I’m working on WordPress related development (ie themes and plugins), I like to run WordPress locally. This is great for trying things out before it goes live and also lets me squeeze in some development time in on the train!
My web server package of choice is XAMMP Lite, the Apache distribution that contains PHP and MySQL. Works great in general, but I had some problems with WordPress permalinks and XAMMP Lite. Here’s the solution.
My XAMMPLite / WordPress Environments
It’s important to note that I keep the XAMMPLite and WordPress environments separate. Rather than copying each WordPress site into the XAMPP Lite structure, I keep it in a separate folder and set up a Virtual Directory pointing to it. This makes it easier to keep track of things.
For example, rather than putting the WordPress installation for the site I’m working on in c:\xampplite\htdocs, I store it in c:\dev\sites\sitename. I then set up a Virtual Directory so that XAMPP Lite’s Apache installation can find the folder and can serve it via http://localhost/sitename.
Now, I’m no Apache expert, but setting up a Virtual Directory was pretty easy: I simply added the following lines to the Apache configuration file (C:\xampplite\apache\conf\httpd.conf), substituting sitename with the appropriate name:
Alias /sitename "C:\dev\sites\sitename"
<Directory "C:\dev\sites\sitename">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
This gave me a virtual directory that worked, but I couldn’t get the WordPress permalinks to work properly.
The Permalink Problem
What was the problem with the permalinks? For me, all of my posts and pages returned a 404 error. Great!
There’s a workaround: put /index.php/ at the start of the permalink structure (ie /index.php/%postname%/). However, while this works, it means that the local permalink structure will be different from that on the live site.
That’s no good for me. The menu links for my themes are often hardcoded, at least to the extent that they will break if the permalink structure changes. I don’t want to have to recode the theme to run it locally!
At least the root cause of the problem was obvious: XAMMP Lite was ignoring the .htaccess file created by WordPress. I just needed to get XAMMP Lite to respect the WordPress .htaccess file. I knew there had to be a way to do this.
The Solution
It turned out the problem was caused by the code I used to set up the Virtual Directory. As I said, I’m no Apache expert! I found the solution on rudy egenias jr’s site. Instead of the code above, I should have entered the following (in the C:\xampplite\apache\conf\httpd.conf file):
Alias /sitename "C:\dev\sites\sitename"
<Directory "C:\dev\sites\sitename">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Note the differences: AllowOverride has changed from None to All. Options has changed from Indexes MultiViews to Indexes FollowSymLinks Includes ExecCGI.
Problem almost solved. There’s one more thing to check to make sure that the WordPress permalinks work: In the httpd.conf file we have to make sure that the following line is uncommented (ie remove the ; before it):
LoadModule rewrite_module modules/mod_rewrite.so
Once that’s done, WordPress Permalinks should work perfectly with XAMMP Lite. Mission accomplished.

