I try to run a website (which works online) on my local server. The site loads without problems, but when I click links with a certain format I get this errors in the X:\xampp\apache\logs:
access.log
::1 - - [18/Jan/2024:14:56:53 +0100] "GET /xtc2/Agip-Novecento:::16131.html HTTP/1.1" 403 299 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
error.log
[Thu Jan 18 14:56:53.289002 2024] [core:error] [pid 3600:tid 1880] (20024)The given path is misformatted or contained invalid characters: [client ::1:52392] AH00127: Cannot map GET /xtc2/Agip-Novecento:::16131.html HTTP/1.1 to file
When I rewrite the link according to the rule in the X:\xampp\htdocs\xtc2\.htaccess
##-- Use colon delimiter ":" for SEO-URLS (default setting)
##-- Categories (:::)
RewriteRule :::([_0-9]+):([_0-9]+)\.html$ index.php?cPath=$1&page=$2 [QSA,L]
RewriteRule :::([_0-9]+)\.html$ index.php?cPath=$1 [QSA,L]
I get a '404 / Forbidden / You don't have permission to access this resource.'
The local server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/7.4.33 Server at localhost Port 80 on a Win 10 machine.
I edited the htacces and manually edited the links, which I tested on different servers.
The "problem" is you are testing this on a Windows server and
:(colon) is not a permitted character in Windows filenames. This is a limitation of the Windows OS.When you make a request to the webserver (Apache in this case), the request gets mapped to the filesystem. It is at this point the "403 Forbidden" response occurs. Unfortunately,
.htaccessis processed after the request has already been mapped to the filesystem, so this cannot be resolved in.htaccess.You might be able to use these rules instead directly in the server config/
<VirtualHost>container (not in a<Directory>container). This is then processed much earlier - before the request is mapped to the filesystem. However, your rules would need to be modified slightly. For example:Note the slash prefix on the substitution string.
However, this still might not resolve the issue. Ordinarily, you would "redirect" such requests (in the server config) to remove these invalid chars.
If you want to run this software on a Windows machine then I would recommend changing the (default) delimiter that is used in URLs.