XAMMPLite Virtual Directory And WordPress Permalinks

| Created: February 22nd, 2009
WordPress Development 16 Comments

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.

Trivia: In the past, I was forced to use IIS as my web server, because Apache had a known bug that conflicted with my Internet connection. Basically, I could have Apache running locally OR an Internet connection, but not both! So IIS it was. However, I recently changed ISP and was freed from this constraint!

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 

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 

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.

16 responses on “XAMMPLite Virtual Directory And WordPress Permalinks

  1. Mike@Atlanta georgia real estate

    So Stephen, during the transition from the virual directory to going live, all of the permalinks were bad? Did this have anything to do with what you said in your trivia comment about changing isps for running locally and internet? Forgive my stupidity, as I am a novice to web-development. I have learned a lot from your posts and thank you for sharing all of your great knowledge.

  2. felix@Hectic Capiznon Bloggers 2009

    mine, I am using EasyPHP2.0 instead but it seems that they have stopped developing this system. I actually tried XAMMP and really find it very helpful with some of my PHP experiments.

  3. Chelle@Pittsburgh Estate Clean Out

    Xaamplite really is great for setting up a local wordpress install – I found that it is great for customizing and building wordpress themes and trying out different things. I was lucky, I didn’t have any problems with the permalinks or anything else 🙂

  4. Bill Bolmeier

    Thanks for this. I run WordPress locally to test various things and stay up-to-date on the current version of WordPress. I’ve always wanted to take the time and resolve this and you’ve done it. Excellent job!!

  5. donnie@Custom Home Theater

    Instead of running WordPress locally, I use a little server that I call my “Sandbox” for prototyping and experimenting. The hardware is just an old P4 that has been retired, but it can run on most anything, even a P3 or Celeron. The software is SME from contribs.org. SME can do lots of things and is a self contained Linux distribution. Check it out.

  6. Shawn@Lawrenceburg Tennessee

    I just started using xammplite last week to practice creating wordpress themes. I noticed this limitation when I started with my first theme but didn’t have time to digg into how to solve it. Luckily I stumbled onto post. This will be a great help when I get around to working on multiple projects at one time.

  7. Emerson @ Montreal Web Design

    I’ve been meaning to get a local copy of wordpress running, but haven’t been able to yet. I find working with servers is so annoying… just give me my CSS and HTML, leave the server work to the real nerds.

  8. noelmoralde

    I have tried XAMMP before but got discouraged by some headaches that pops up every now and then. I have not tried XAMMPLite but I assume the headaches I’d get would be the same, hopefully ‘lite-r’ if I try it. These days, I’m using MoWeS Portable. I can attest to its bug-free headache-free performance. I installed it in my flashdrive and I can take all my work wherever I like, in whichever computer.

  9. kees

    Thanks for this. I made the virtual hosts with your solution in Mamp (Mac) and it works perfect. Now I can enjoy my pretty permalinks locally

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: