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 example.org, 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?

1 Answer 1


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.

  • 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? May 4, 2010 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, 2010 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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