All pastes #42171 Raw Edit

cho@shyne.ch

public text v1 · immutable
#42171 ·published 2006-02-20 01:56 UTC
rendered paste body
mod_rewrite problem

I want to do the following:
- in the directory /help/ forward all requests for non-existing documents or folders to a script which is in the same folder, but leave access to existing documents and folders in /help/ untouched
- the phrase the user entered - something like www.mydomain.org/help/Hallo Welt - should be passed as an argument to the script
- the user should not see, that he/she is being forwarded

Problem:
- existing documents get forwarded
- non existing documents produce a 404
- a simple ErrorDoument 404 /help/index.php won't do, because the user should not see that he/she is getting forwarded

Here are the directives:

<VirtualHost *:80>
...

   RewriteEngine on
   RewriteCond /help/%(REQUEST_URI) !-d
   RewriteCond /help/%(REQUEST_URI) !-f

   RewriteRule ^help/?(.*)$ /help/index.php?id=$1 [L,QSA]

</VirtualHost>


- I am not sure if /help/%(REQUEST_URI) points to the right place, but RewriteBase is not permitted in VirtualHost directives
- Should it be ^help/ or ^/help/
...

Does somebody have an idea, how to solve this? -> cho@shyne.ch
Thanks!