Mobile app version of vmapp.org
Login or Join
Looi9037786

: Htaccess 404 & 301 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

@Looi9037786

Posted in: #Htaccess #Redirects

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 www.example.com/realms-of-hyrule/legend-of-zelda/maps

I go to 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 address.

My questions:


Why doesn't the range of numbers [1-9] work?
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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Looi9037786

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sims2060225

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 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).
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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme