Skip to main content
Tweeted twitter.com/StackWebmasters/status/673374712475623424
Grammar, formatting, removed "thanks" / signature
Source Link
MrWhite
  • 43.1k
  • 4
  • 50
  • 90

I'm having problems with the following while config. on my Apache server to Rewrite some urlsURLs.

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.config used to work perfectly fine until I used SetEnv PATH...SetEnv PATH etc. I need to use this because there are lots of rules, not just those mentioned above.

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/barwww.site.com/foo/bar for instance).

Apache returns the ErrorDocument if iI 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.

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.

I'm having problems with the following config on 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 config used to work perfectly until I used SetEnv PATH etc. I need to use this because there are lots of rules, not just those mentioned above.

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.

Post Migrated Here from serverfault.com (revisions)
Source Link
misterte
misterte

Using env variables with RewriteRule and ErrorDocument

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.