Apache 2.4.56 MOD_REWRITE is not working for /cgi-bin/

113 Views Asked by At

1.) I have a question related to MOD_REWRITE in file C:\xampp\htdocs\.htaccess.

It seems to work well in any directory except /cgi-bin/.

For example, when I try to switch from http:// to https:// by using the following RewriteRule:

RewriteCond %{SERVER_PORT} !^443$

RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

It won't switch to https:// for an URL like: http://localhost/cgi-bin/test.cgi

While it does this pretty well for an URL like: http://localhost/test.html

2.) Is there something wrong with my C:\xampp\apache\conf\httpd.conf? Or do i need to place another .htaccess-File copy in the cgi-bin-Folder? In order to work correctly? But when I try to do so, my webbrowser says that I dont have permission to access the CGI-scripts in /cgi-bin/ by telling me:

For example: URL: http://localhost/cgi-bin/Test1.cgi

Results in:

"Forbidden

You don't have permission to access this resource."

Apache/2.4.56 (Win64) OpenSSL/1.1.1t PHP/8.2.4 Server at localhost Port 80

Iam using Windows7 Pro with XAMPP. Firefox Version 115.

I tried to copy the .htaccess-File from DocumentRoot / to /cgi-bin with result Error 403 Forbidden.

Thanks for your answers in advance.

1

There are 1 best solutions below

0
On

One answer is as follows: C:\xampp\apache\conf\httpd.conf: "Maybe the script alias directive for /cgi-bin is taking priority over the rewrite? Remove the script alias for the http site and see if it's better."

With this it makes fine https:// - URLS, but I'm receiving a Redirection-Error in my Browser. Unable to load any pages from the server.