Many websites can be accessed with a FQDN (i.e., appending a dot to the TLD):
- https://www.ebay.com./
- https://www.google.com./
- https://www.reddit.com./
- https://stackoverflow.com./
- https://en.wikipedia.org./wiki/Main_Page
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]
来源:https://stackoverflow.com/questions/13309854/redirect-urls-with-fqdn-dot-after-tld-to-equivalent-with-pqdn