[SOLVED] CGI execution error whenever I use htaccess file
CentOSThis forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a Linux Server, running Centos 6.9, Apache 2.2.15, Postfix 2.6.6 and all those known common stuff.
In order to set Error pages, Cache time for some types of files, as well as to adapt to Google requirements about having Domains with and without "www", I have at each Domain's root directory, an .htaccess file like this one you can see at the bottom.
The problem: if under any Domain I have a Site which uses .cgi files, they all stop working and I receive messages like Page Not Found for any of them.
In order to avoid this error I have to comment out all the Redirect lines, as you can see in the .htaccess below.
So, please, I need help, because I need such an .htaccess file, but my CGI's have to keep working.
Thanks a lot in advance.
Mario Lima./
_______________________________________________________________
The problem: if under any Domain I have a Site which uses .cgi files, they all stop working and I receive messages like Page Not Found for any of them.
Could you please post the exact error from the apache error_log?
Quote:
In order to avoid this error I have to comment out all the Redirect lines, as you can see in the .htaccess below.
You can ditch mod_rewrite and use a virtual host like this:
Code:
<VirtualHost *:80>
ServerName www.corretoresdeseguros.com.br
ServerAlias corretoresdeseguros.com.br
<- The rest of vhost stuff ->
</VirtualHost>
Regards
Last edited by bathory; 03-28-2018 at 07:43 AM.
Reason: forgot a word!
Thanks for your help. As a matter of fact, all of our Domains have <virtualhost> blocks with ServerName and ServerAlias, like this you mentioned.
When I activate the .htaccess file, the error which occurs to any CGI we try to use is:
PAGE NOT FOUND
So since you have both names, there is no need of the rewrite rules. Apache can serve stuff like pages, cgi scripts etc, using both names.
Unless you want to do something else, i.e. use mandatory www prefix.
And please post the error from the apache logfile (in Centos is in /var/log/httpd/error_log), so we could see why you get the "PAGE NOT FOUND" error in the browser.
1) We use these lines with redirect because Google requires to do this way, so that Google does not consider with "www" and without "www" as being two different sites.
2) The error log messages are like this one:
[Wed Mar 28 11:20:03 2018] [error] [client 201.6.232.101] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/html/multisites/www/cgi-multisites/ezformmx.cgi
1) We use these lines with redirect because Google requires to do this way, so that Google does not consider with "www" and without "www" as being two different sites.
That's what I' telling you.
If you have both names (with and without the www prefix) in the apache ServerName/ServerAlias directives of the appropriate VirtualHost and if of course those 2 names resolve by dns to your apache server, there is no need to use rewrites.
Quote:
2) The error log messages are like this one:
[Wed Mar 28 11:20:03 2018] [error] [client 201.6.232.101] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/html/multisites/www/cgi-multisites/ezformmx.cgi
This log entry does not give a 404 (Not Found) error, so there must be something else.
If apache thinks that FollowSymLinks is off, then most likely it does not read .htaccess. You can use either one of the following:
Based in your comments, I reviewed all the lines and I found two inconsistences. I altered and now it is all working, the .htaccess rules as well as the CGI scripts. The inconsistences were:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.