Apache Rewrite to File System Or Proxy -


i want create apache mod_rewrite rule two things:

  1. serve contents of file system directory when /file-system-target requested and
  2. proxy whenever /file-system-target not requested.

e.g.:

rewriterule ^/file-system-target /path/to/file/system/target [l] rewriterule ^/(.*) http://localhost:8080 [p] 

however when watching output of rewritelog, latter rule matched , former never matched. missing?

as turns out, statement "latter rule matched & former never matched" may not have been true; had confusing httpd.conf in rewrite logging enabled in more 1 place.

in event, first rule incomplete. should this:

rewriterule ^/file-system-target(.+)$ /path/to/file/system/target/$1 [l] 

i added additional rule handle (lack of) trailing slash:

rewriterule ^/file-system-target$ /path/to/file/system/target/$1 [l] 

so ended with:

rewriterule ^/file-system-target$ /path/to/file/system/target/$1 [l] rewriterule ^/file-system-target(.+)$ /path/to/file/system/target/$1 [l] rewriterule ^/(.*) http://localhost:8080 [p] 

i'm going assume there more elegant ways implement feature, i'm satisfied enough above configuration call task "done".


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -