views:

40

answers:

1

My Perl app reveals the filename 'processing.cgi' in the addressbar when running on my hosting account, but on localhost it seems to work fine, that is, it doesn't reveal the filename 'processing.cgi'.

Here's .htaccess thats exactly the same on both locations:

AddHandler cgi-script .cgi
Options +ExecCGI 

IndexIgnore *
DirectoryIndex processing.cgi

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ processing.cgi/$1

RewriteRule ^$ processing.cgi [L]
RewriteRule ^/$ processing.cgi [L]

This is the .htaccess in /public_html:

Options -Indexes 

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.main-domain\.com$ [NC]
RewriteRule ^(.*)$ http://main-domain\.com/$1 [R=301,L]

# BEGIN WordPress
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L]
# </IfModule>

# END WordPress

What do I need to change?

Many thanks for your help!

+2  A: 

With current setup, if you type http://example.com/ in your browser location bar there is no possible way you can see processing.cgi in such location bar unless your Perl script performs an HTTP redirection (by sending the Location header). So I suggest you double-check your Perl code.

Whatever, I see what appear to be many directives scattered random around the file. I think it'll be more productive if I explain what they mean:

AddHandler cgi-script .cgi
Options +ExecCGI 

Enable CGI scripts and map the *.cgi extension so any file that ends with .cgi is considered a program.

IndexIgnore *

Instruct Apache to generate empty directory listings. When people do not want directory listings, they normally just disable them: Options -Indexes

DirectoryIndex processing.cgi

When the URL points to a directory, find and display a file called processing.cgi in such directory. Are you planning to maintain a copy of your Perl program on every directory of your site?

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

If the URL doesn't map to an existing file or directory...

RewriteRule ^(.*)$ processing.cgi/$1

When user types http://example.com/foo/bar.jpg actually run http://example.com/processing.cgi/foo/bar.jpg. See if any other rules matches.

RewriteRule ^$ processing.cgi [L]

When user types http://example.com actually run http://example.com/processing.cgi. We're done with rules.

RewriteRule ^/$ processing.cgi [L]

When user types http://example.com/ actually run http://example.com/processing.cgi. We're done with rules.

It's clear now that you have a lot of redundant rules. Your exact needs are not 100% clear to me but I guess you can savely remove most of your directives:

AddHandler cgi-script .cgi
Options +ExecCGI

Options -Indexes

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ processing.cgi/$1 [L]
Álvaro G. Vicario
Many thanks for the explaination. I tried your rules and it resulted in a 403 error. The problem is, when using the app, I can see processing.cgi in the addressbar. So for example, the url reads: http://domain.com/processing.cgi/add. I want it to be simply domain.com/add
Nimbuz
I've tested the directives myself and they work as expected. I insist: none of the directives you've posted perform an HTTP redirection. Seriously. Do you have *other* directives somewhere else? Have you reviewed your Perl code?
Álvaro G. Vicario
How is it possible that the same app (without any changes) works well locally and not on the server.
Nimbuz
It's possible if you have other directives somewhere else or if the Perl code makes HTTP redirections based upon environment values.
Álvaro G. Vicario
Yes, I have .htaccess in public_html too (this domain is an addon domain hosted at public_html/addondomain.com/), please see my edit in the original post for the htaccess in /public_html
Nimbuz
Ah, so the host said : We actually run LiteSpeed Web Server, not Apache. It's about 99.9% apache compatible, but you may have run into a situation where it handles things just a bit differently than Apache. There really is nothing for us to look into as we can not 'tweak' configurations on a per-site basis.
Nimbuz
At http://www.litespeedtech.com/litespeed-web-server-features.html they explictly claim: *LiteSpeed Web Server's rewrite engine is fully compatible with Apache mod_rewrite so there is no need to change rewrite directives when you switch to LiteSpeed*. Triggering an HTTP redirection when Apache would not is a major difference; I don't think it's the case. We are going nowhere if you don't check your Perl code. (BTW, you can probably remove your main .htaccess file since it appears to redirect to an invalid domain).
Álvaro G. Vicario