First, your code is deficient in that it requires that the {REQUEST_URI} match BOTH the_work/ and the_work successively (those are ANDed in your code) then the page will be redirected to /index.php and then be ANDed with the following mod_rewrite code.
THe problems can easily be resolved by using the optional notation and using the Last flag to terminate the block statement (as you would with ; or }). Sometimes, too, Apache does NOT like to see the leading / in the redirection as it confuses the DocumentRoot with the server’s physical root - but that’s with an Apache that’s ready to fall over.
RewriteEngine on
RewriteRule ^the_work/? index.php?page=the_work [L]
inclick,
Thanks for the help but your code will generate an infinite loop on Apache 1.x and will not work at all on Apache 2.x.
The Apache version problem is caused by the leading / in your regex which is required for a DocumentRoot in Apache 1.x and will prevent a match with Apache 2.x. If you’re not sure which version you’re using, either don’t use the start anchor (^ - which you didn’t use) or make it optional (/?).
The “loopy” problem is that your redirection will be matched on the next pass through mod_rewrite, i.e., ([^/]*) will match index.php and loop.
To me, using a “catch-all” like ([^/]) is almost as bad as using the dreaded :kaioken: EVERYTHING :kaioken: atom ( the (.) ) as it only eliminates the / from the list of matching characters. BE SPECIFIC in what you match to avoid problems (and check that the regex will not match the redirection)!