mod rewrite & cgi-bin perl error (403 forbidden)

Oh, the strange things mod_rewrite does!

mod rewrite & cgi-bin perl error (403 forbidden)

Postby marjan » Wed Oct 14, 2009 4:47 am

Hi,
the problem I have can be googled, the solution to it can't;)

I have some mod rewrite rules in the .htaccess file and some perl scripts in cgi-bin directory;

.htaccess RewriteEngine on makes all the rules work ok but when i want to run any of the perl scripts I get 403 Forbidden error page;

RewriteEngine off makes cgi-bin located scripts work fine but at the same time rewrite rules don't (error 404);

what can be wrong?
can these two be used and working at the same time?
thanks in advanced;
Marek
Last edited by marjan on Thu Oct 15, 2009 12:23 am, edited 1 time in total.
marjan
 
Posts: 3
Joined: Wed Oct 14, 2009 4:17 am

Postby richardk » Wed Oct 14, 2009 2:18 pm

Where is the mod_rewrite (which .htaccess file)?
What are the rules?
Do you have access tio your error_log? (What does it say is causing the error?)
Do you get a 500 error from HTML files in your /cgi-bin?
Is the /cgi-bin in your document root (eg. /document/root/public_html/cgi-bin) or is it at the same directory level eg. (/document/root/cgi-bin)?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby marjan » Wed Oct 14, 2009 11:54 pm

Thanks for your reply;

Where is the mod_rewrite (which .htaccess file)?
/document/root/public_html/

What are the rules?
RewriteEngine on
RewriteRule ^.*(xxxx),([0-9]+)/?$ http://xxx.com/index.php?page=$1&d=$2 [L]
RewriteRule ^.*(yyyy),([0-9]+),([0-9]+)/?$ http://xxx.com/index.php?page=$1&d=$2&s=$3 [L]
ErrorDocument 404 http://xxx.com/error_page.php

Do you have access tio your error_log? (What does it say is causing the error?)
No (web hosting)

Do you get a 500 error from HTML files in your /cgi-bin?
Yes, if the rules are incorrect;
this is where I get 403 (Forbidden) error no matter if there are perl (chmod 755) or html files

Is the /cgi-bin in your document root (eg. /document/root/public_html/cgi-bin) or is it at the same directory level eg. (/document/root/cgi-bin)?
/document/root/public_html/cgi-bin
marjan
 
Posts: 3
Joined: Wed Oct 14, 2009 4:17 am

Postby richardk » Thu Oct 15, 2009 2:17 pm

Do the rules need to apply to the /cgi-bin directory?

Try adding
Code: Select all
RewriteEngine Off

in /cgi-bin/.htaccess.

Or try
Code: Select all
ErrorDocument 404 http://xxx.com/error_page.php
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^.*(xxxx),([0-9]+)/?$          /index.php?page=$1&d=$2      [L]
RewriteRule ^.*(yyyy),([0-9]+),([0-9]+)/?$ /index.php?page=$1&d=$2&s=$3 [L]

in /.htaccess.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby marjan » Fri Oct 16, 2009 6:33 am

Do the rules need to apply to the /cgi-bin directory?
RewriteEngine Off

They do not, already tried that; does not work

I also tried the other way with /.htaccess; does not work either.

I wrote to my hosting provider about this problem, did not get reply yet.
Is it possible that apache's configuration they got is incorrect?
It seems that turning RewriteEngine On makes the cgi-bin access forbidden (wrong thinking i guess);

thanks again,
Marek
marjan
 
Posts: 3
Joined: Wed Oct 14, 2009 4:17 am

Postby richardk » Sat Oct 17, 2009 6:22 am

I also tried the other way with /.htaccess; does not work either.

It should have been
Code: Select all
ErrorDocument 404 http://xxx.com/error_page.php
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/cgi-bin(/.*)?$
RewriteRule ^.*(xxxx),([0-9]+)/?$          /index.php?page=$1&d=$2      [L]
RewriteCond %{REQUEST_URI} !^/cgi-bin(/.*)?$
RewriteRule ^.*(yyyy),([0-9]+),([0-9]+)/?$ /index.php?page=$1&d=$2&s=$3 [L]


Is it possible that apache's configuration they got is incorrect?

Without seeing the error log i can only guess, but i would think that mod_rewrite is disallowed in /cgi-bin and so the mod_rewrite in /.htaccess causes the 500 error.

It seems that turning RewriteEngine On makes the cgi-bin access forbidden (wrong thinking i guess);

If you only put only
Code: Select all
RewriteEngine On

in /.htaccess do you get a 500 error in /cgi-bin?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 16 guests

cron