The following is the GNU All-permissive License as recommended in https://www.gnu.org/licenses/license-recommendations.en.html
Copyright (C) 2024 Free Software Foundation sysadmin@fsf.org
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
Contributions are welcome. See https://savannah.gnu.org/maintenance/fsf/.
apache guides
rewrites, redirects, aliases
If you have a rewrite rule in apache for all of "/wiki", then that will take precedence over any redirects in place. that is because the rewrite module has overall precedence. So convert your redirect to a rewrite rule, like the following:
RewriteRule "^/wiki/En.swpat.org:About$" "/wiki/ESP:About" [R]
It may also be possible to use 'Alias' instead of a rewrite rule, so you can make use of redirects rather than rewrites:
Alias /wiki /var/www/w/index.php
vs
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
redirect many HTTP domains to HTTPS while working with HSTS
Background: When redirecting from HTTP to HTTPS, the domain names of both URLs
should be the same. This allows browsers to respect our HSTS settings, which
tell it to always go directly to the HTTPS site even if https://
is not typed
at the beginning of the URL.
If we only redirect all port 80 connections for all virtual domains to a single target domain, the URLs will vary between the original and target domain names, so HSTS wouldn't work. Here is how to set this up in Apache:
Enable the rewrite
module:
a2enmod rewrite
Add to your Apache virtual host config for port 80:
RewriteEngine on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
Reload Apache:
systemctl reload apache2
Example of testing:
rm .wget-hsts
wget emailselfdefense.com
wget emailselfdefense.com
The second time, there should be a message about HSTS at the top of the output. Also check the flow of URLs that wget follows as it reaches the target domain.
To confirm that the correct target is reached and that things are generally not broken, you can also clear the cache from your browser to remove any stale redirects from previous use, and then test out http://emailselfdefense.com in your browser, confirming that everything looks correct.