0

The site runs on WordPress (latest) and is installed in /htdocs/www/. This htaccess file is in /htdocs/www/roh/ along with a bunch of images and some CSS.

I want requests to the old html files to redirect to their new WordPress pages. I got most of it working, except the example below.

RewriteEngine On
RewriteBase /htdocs/www
ErrorDocument 404 /htdocs/www/
Redirect /roh/z1/q2lvl[1-9].html http://www.example.com/realms-of-hyrule/legend-of-zelda/maps

I go to www.example.com/roh/z1/q2lvl2.html, and it 404s and takes me to the main 404 page in my WordPress theme.

I tried ErrorDocument 404 /htdocs/www/roh/404.html, but that just got me an ISP redirected spam search page. The only way I got the main WordPress 404 page working was by going up directories until something worked. I do not want to send 404s to an http:// address.

My questions:

  1. Why doesn't the range of numbers [1-9] work?

  2. Why can't I get /htdocs/www/roh/404.html working for anything in /roh and below?

Sorry for the basic questions, not exactly sure what to search for, so Google is only giving me examples I've tried or have working already.

1 Answer 1

1
  1. Use RedirectMatch directive instead. Redirect does strict string comparison while RedirectMatch uses regular expressions and therefore can be "dynamic".

    RedirectMatch 301 /roh/z1/q2lvl[1-9].html http://www.example.com/realms-of-hyrule/legend-of-zelda/maps
    

    BTW, if you are using Redirect and/or RedirectMatch directives only, then no need for RewriteEngine or RewriteBase (those are from 2 different modules).

  2. Not sure -- but maybe because RewriteRules from folder above come into play... Rewrite debugging usually can shed some light on what is going on (it can show which 404 file Apache is trying to use, as rewrite rules got applied to it as well).. but for that you have to be able to edit server config or virtual host config.

1
  • Thanks much, that fixed it! :) If I can figure out the 404 page, will post back here. :)
    – gpryatel
    Aug 11, 2011 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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