Many websites can be accessed with a FQDN (i.e., appending a dot to the TLD):
Some sites can’t be accessed that way, but I can’t find an example right now.¹ ²
Is it possible, within a .htaccess
file, to redirect all variants with the dot suffix to the variants without?
Ideally with a "wildcard" rule, so that you don’t have to list the domains explicitly (for using it on different sites/domains without editing).
Example redirects:
http://example.com./
→http://example.com/
http://example.com./foo
→http://example.com/foo
http://sub.example.com./bar.html
→http://sub.example.com/bar.html
¹ stackoverflow.com, when accessed over HTTP, used to give HTTP error 400: "Bad Request - Invalid Hostname".
² Wikipedia, when accessed over HTTPS (when it was still optional), used to give a certificate error: "The certificate is only valid for the following names: *.wikipedia.org
, wikipedia.org
(Error code: ssl_error_bad_cert_domain)
This should work :
RewriteCond %{HTTP_HOST} ^([a-z0-9\.-]+)\.com\.$
RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With