Forum Moderators: phranque
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.+)$ "https://%{HTTP_HOST}/$1" [R=301,L] http://localhost/cgi-bin/test.cgi http://localhost/test.html http://localhost/cgi-bin/Test1.cgi "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 RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.+)$ "https://%{HTTP_HOST}/$1" [R=301,L]
#Workaround for cgi-bin. But still no effect on Urls containing /cgi-bin/.
RewriteRule ^cgi-bin https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index(\.php|\.html|\.htm)$ "/cgi-bin/forum.cgi" [L,NC]
RewriteRule ^caseindexci(\d*)pnc(\d*)pn(\d*)kat(\d*)ne(\d*)[^\.]*.html(#?\d*)$ "/cgi-bin/forum.cgi/case?caseid=$1&pagenumcase=$2&pagenum=$3&kat_id=$4&ne=$5$6" [L,NC,QSA]
RewriteRule ^mainindexpn(\d*)kat(\d*).html(#?\d*)$ "http://localhost/cgi-bin/forum.cgi?pagenum=$1&kat_id=$2$3" [L,NC,QSA]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.+)$ "https://%{HTTP_HOST}/$1" [R=301,L] RewriteRule ^(.+)$ "https://%{HTTP_HOST}/$1" [R=301,L]
is better expressed as RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
Asterisk * instead of plus + to cover requests for the root. Anchors aren't necessary, because Regular Expressions are greedy by default; quotation marks in the target aren't necessary at all. So that saves your server four bytes on every request ;) RewriteRule ^index(\.php|\.html|\.htm)$can be simplified to RewriteRule ^index\.(php|html?)$... except why would you? No legitimate visitor will include “index.xtn” in their request, unless that was a visible part of the URL in some earlier iteration of the site. And even then, it would only be one specific extension, not any-and-all. has anyone an idea regarding to why the webbrowser switches to https:// for urls without /cgi-bin/.Isn't that simply the issue you described in the initial post? The RewriteRule executes as intended everywhere but /cgi-bin/
And why that fails for all urls containing /cgi-bin/ ? ) "https://%{HTTP_HOST}/$1" [R=301,L]
RewriteRule ^caseindexci(\d*)pnc(\d*)pn(\d*)kat(\d*)ne(\d*)[^\.]*.html(#?\d*)$ "/cgi-bin/forum.cgi/case?caseid=$1&pagenumcase=$2&pagenum=$3&kat_id=$4&ne=$5$6" [L,NC,QSA]
RewriteRule ^mainindexpn(\d*)kat(\d*).html(#?\d*)$ "http://localhost/cgi-bin/forum.cgi?pagenum=$1&kat_id=$2$3" [L,NC,QSA]In each case, it should be \.html (excaped . dot), though in each case it's a non-lethal error because of the immediately preceding character. More importantly, fragments # are not part of the request; they are used internally by the visitor's browser. You can redirect to a fragment, but not from one.
<Directory "C:/xampp/cgi-bin">
AllowOverride All
Options None
Require all granted
</Directory> XAMPP is not meant for production use but only for development environments. XAMPP is configured to be open as possible to allow the developer anything he/she wants. For development environments, this is great but in a production environment, it could be fatal.
Here a list of missing security in XAMPP:
The MySQL administrator (root) has no password.
The MySQL daemon is accessible via network.
ProFTPD uses the password "lampp" for user "daemon".
The default users of Mercury and FileZilla are known.
All points can be a huge security risk. Especially if XAMPP is accessible via network and people outside your LAN. It can also help to use a firewall or a (NAT) router. In case of a router or firewall, your PC is normally not accessible via network. It is up to you to fix these problems. As a small help there is the "XAMPP Security console".
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L] httpd.conf: ScriptAlias /cgi-bin/ "C:/xampp/cgi-bin/" because the cgi-bin-folder is not situated/created under C:/xampp/htdocs. So the RewriteRules for my DocumentRoot C:/xampp/htdocs wont work for the external path C:/xampp/cgi-bin. This must be the point of failure. Would I have created cgi-bin in C:/xampp/htdocs (C:/xampp/htdocs/cgi-bin), it might perhaps be executing my RewriteRules there. Maybe, I'm testing that in the nearest future. ScriptAlias /cgi-bin/ "C:/xampp/htdocs/cgi-bin/" 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 443
2 different WebServers and Environment Variables:
1.) Internet Service Provider:
DOCUMENT_ROOT="/home/strato/http/power/rid/18/95/54631895/htdocs"
SCRIPT_FILENAME="/home/strato/http/power/rid/18/95/54631895/htdocs/cgi-bin/printenv.cgi"
SCRIPT_NAME="/cgi-bin/printenv.cgi"
2.) Localhost XAMPP-Installation:
DOCUMENT_ROOT="C:/xampp/htdocs"
SCRIPT_FILENAME="C:/xampp/cgi-bin/printenv.cgi"
SCRIPT_NAME="/cgi-bin/printenv.cgi"