I’m trying to expose a CGI file as my document root and web server. I do not want to expose the fact that the server is running a CGI script.
How can I map a URL http://host/index.cgi/ back to http://host/ in Apache2? I’m guessing it involves mod-rewrite, but I haven’t finished grokking all the docs yet.
The following configuration is working, but I’m guessing there is a more complete solution:
RewriteEngine ON
Redirect /index.cgi/ /
Correct solution using mod-rewrite.
Update CGI script to rewrite URLs to desired path. This means that URLS like
index.cgi/pathchange to/app1/pathor in my case, just/path. For my script there was an option calledvirutal-rootthat made a global change.Then udpate Apache with the following directives. What it does, is internally rewrite all the URLs to include the CGI script, but ignore URLs going to the actual script.
One sticking point, is that if the CGI script references any static files on the server, they need to be placed in a path that is also out of the rewrite rule. So for example, exclude another path, before the RewriteRule: