As an example, I was expecting this
https://example.software/credits
to evaluate to an internal rewrite
https://example.software?mode=credits
Why is it showing up on the browser url-bar as a 302 redirect?
RewriteEngine On
#Put in by the hosting company to enforce https
RewriteCond %{HTTP_HOST} example\.software [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.software/$1 [R,L]
#Bunch of domains, not being used yet
RewriteCond %{HTTP_HOST} ^example\.app$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.app$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example\.kiwi$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.kiwi$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example\.nz$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.nz$ [NC,OR]
RewriteCond %{HTTP_HOST} ^example\.online$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.online$ [NC]
RewriteRule ^ https://example.software/$1 [R=302,L]
#Internal redirects
RewriteCond %{HTTP_HOST} ^example.software$ [NC]
RewriteRule ^home$ https://example.software\?mode\=home&%{QUERY_STRING} [L]
RewriteRule ^contacts$ https://example.software\?mode\=contacts&%{QUERY_STRING} [L]
RewriteRule ^credits$ https://example.software\?mode\=credits&%{QUERY_STRING} [L]
RewriteRule ^downloads$ https://example.software\?mode\=downloads&%{QUERY_STRING} [L]
RewriteRule ^developer$ https://example.software\?mode\=developer&%{QUERY_STRING} [L]
RewriteRule ^projects$ https://example.software\?mode\=projects&%{QUERY_STRING} [L]
RewriteRule ^(download)/([^/]+)$ https://example.software?mode=$1&name=$2 [L]
RewriteRule ^(code)/([^/]+)$ https://example.software?mode=$1&name=$2 [L]
RewriteRule ^(payment)/([^/]+)$ https://example.software?mode=$1&name=$2 [L]
RewriteRule ^(donation)/([^/]+)$ https://example.software?mode=payment&name=$2 [L]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
Header append X-Frame-Options: "SAMEORIGIN"
Header append X-Content-Type-Options: "nosniff"
#Internal redirects
section, theRewriteCond
directive only applies to the very firstRewriteRule
directive that follows. However, it looks like the intention is that it applies to all theRewriteRule
directives that follow - but that is not the case. The remainingRewriteRule
directives are processed unconditionally (ie. for every domain). To avoid repeating the same condition before every rule, you could instead write an additional rule that skips (S
flag) the following rules when the requestedHost
is not the domain in question.RewriteCond
directive) is perhaps redundant anyway. (Unless you are not redirecting all the domains?)