将带有 FQDN(TLD 后的点)的 URL 重定向到与 PQDN 等效的 URL [英] Redirect URLs with FQDN (dot after TLD) to equivalent with PQDN
问题描述
可以使用FQDN (即,在 TLD 后附加一个点):
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.¹ ²
是否可以在 .htaccess
文件中将所有带点后缀的变体重定向到没有后缀的变体?
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).
重定向示例:
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
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,当通过 HTTP 访问时,用于给出 HTTP 错误 400:错误的请求 - 无效的主机名".
¹ stackoverflow.com, when accessed over HTTP, used to give HTTP error 400: "Bad Request - Invalid Hostname".
² 维基百科,当通过 HTTPS 访问时(当它仍然是可选的)时,用于给出证书错误:证书仅对以下名称有效:*.wikipedia.org
,<代码>wikipedia.org(错误代码:ssl_error_bad_cert_domain)
² 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)
推荐答案
这应该有效:
RewriteCond %{HTTP_HOST} ^([a-z0-9.-]+).com.$
RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]
这篇关于将带有 FQDN(TLD 后的点)的 URL 重定向到与 PQDN 等效的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!