Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's the situation: I've got an old WordPress installation that I'd like to archive as static files, but I'd also like to preserve old URLs. I've already created the static archive with wget and sorted out the filenames and links. Now I'd like to configure Apache to intercept requests for the old dynamic URL and replace them with the new static one, e.g.:


should redirect to

I've tried adding the following to the VirtualHost config for, but to no effect -- I just get the PHP page.

RewriteCond %{REQUEST_URI} /log/
RewriteCond %{QUERY_STRING} p=([^&;]*)
RewriteRule ^/$ http://%{SERVER_NAME}/log/archives/%1.html [R,L]

I've enabled logging and I can see what look like other rules being applied, but not this one. None of my other guesses at match patterns for %{REQUEST_URI} seem to have any effect either (log, log/, log.*, even .*).

I'm new to mod_rewrite and this is mostly cargo cult, so I'm pretty sure I've gotten it wrong. Anyone know what I should be doing here?

share|improve this question
up vote 1 down vote accepted

Try Changing RewriteRule ^/$ to RewriteRule ^/log/*$

As it is, your rule will never match anything because

RewriteCond %{REQUEST_URI} /log/

States that the URL must contain /log/ however

RewriteRule ^/$...

Will only match / exactly -- that is, the top level directory.

share|improve this answer
Thanks! Exactly right, and stupid of me. On a related note, do you know if there's a way I can strip the query string from the redirected URL? – David Moles May 4 '10 at 7:03
Well, I'm not sure. I would have expected the query string to have been stripped given the RewriteRule you provided... sounds like you should post that as a new question :-) – Josh May 4 '10 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.