This page is READ-ONLY. It is generated from the old site.
All timestamps are relative to 2013 (when this page is generated).
If you are looking for TeX support, please go to VietTUG.org

dispatch.fcgi: how to change xxx's extension

index.html => index.zzz in dispatch.fcgi
Added by about 3 years ago

When deploying one of my applications that uses dispatch.fcgi, I have the following stuff in .htaccess:

AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

This seemed to be perfect, until I found that if there's a file news.html in the root directory (responds to /news.html) and there's also a response of my application to /news/. If the user requests www.foobar.com/news, the apache transfers this request to /news.html, and because such file does exist, he/she would never get the application's reply (he would get the contents of news.html instead.)

This schema is quite annoyed. I searched through internet but I didn't find a suitable solution (I expected to find a way to change the extension in the .htaccess configuration, to replace .html by something else.) I even read the source of dispatch.fcgi, and fcgi_handler.rb (oops, I am using Ruby). So disappointed.

Finally I decided to give me a try

AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI

RewriteRule ^$ index.zzz [QSA]
RewriteRule ^([^.]+)$ $1.zzz [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Thanks God. It works. The user now can access /news.html, and /news/ from my application.


Comments