Using env variables with RewriteRule and ErrorDocument
Posted
by
misterte
on Pro Webmasters
See other posts from Pro Webmasters
or by misterte
Published on 2011-02-21T20:56:03Z
Indexed on
2011/02/21
23:34 UTC
Read the original article
Hit count: 326
apache
|mod-rewrite
Hi,
I'm having problems with the following while config. my Apache server to Rewrite some urls.
SetEnv PATH_TO_DIR /directory
RewriteRule ^%{PATH_TO_DIR}/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-\.]+)/?$ /index.php?dir=$1&file=$2
ErrorDocument 404 %{PATH_TO_DIR}/index.php?dir=null&file=error
This conf. used to work perfectly fine until I used SetEnv PATH... etc. I need to use this because there are lots of rules, not just those.
Can anyone point out my mistake?
Apache returns
%{PATH_TO_DIR}/index.php?dir=null&file=error
when I try anything (www.site.com/foo/bar for instance).
Apache returns the ErrorDocument if i just try to fetch the index.
I know it's not a problem with the rewrite rules because they work when I remove the PATH_TO_DIR variable and just hard code it.
Thanks!
A.
© Pro Webmasters or respective owner