0

I already have an awk script called viewzip.cgi which works as follows:

...viewzip.cgi/path_to_zipfile/zipfile.zip/

will show the root directory of that file,

...viewzip.cgi/path_to_zipfile/zipfile.zip/subdir/

shows a subdirectory (if present)

...viewzip.cgi/path_to_zipfile/zipfile.zip/path_to_file/file

will download one particular file.

Now what I want is omitting the "viewzip.cgi" part in the URL and an automatic redirect working as follows:

...path_to_zipfile/zipfile.zip

should download the zipfile as it would be standard behaviour, but

...path_to_zipfile/zipfile.zip/

with the trailing slash should redirect to a path like the first example, and also when trailing subdirs or files are appended.

How can I do that, if so? I have access to file system (i.e. ".htaccess") but not to apache's root configuration files. Or is there a (possibly well-known) better solution? A similar problem applies to .chm files which would be more easily browseable when unpacked on server on request. It would be nice if I don't need to repeat a redirection line for each single zipfile I have.

henni

  • Questions describing your requirements and asking someone to write the code for you or explain how to write the code are off-topic for Stack Overflow. Please identify a specific problem or question about programming. Include attempted solutions, an explanation of how the results differ from the desired results, and any error messages you receive. Please read the [About](http://stackoverflow.com/about) page and [this advice on asking good questions](http://stackoverflow.com/help/how-to-ask). – Adi Inbar Apr 09 '14 at 23:36

1 Answers1

0

The RedirectMatch keyword does the job.

RedirectMatch .../((?!viewzip\.cgi/).*)\.zip/(.*) http://www.../.../viewzip.cgi/$1.zip/$2
user2699548
  • 271
  • 3
  • 2