将带有FQDN的URL(TLD后加点)重定向为与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
- 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
¹通过HTTP进行访问时,stackoverflow.com会产生HTTP错误400:错误请求-无效的主机名。
¹ stackoverflow.com, when accessed over HTTP, used to give HTTP error 400: "Bad Request - Invalid Hostname".
²Wikipedia,当通过HTTPS访问时(仍然是可选的),用于给出证书错误:证书仅对以下名称有效: *。wikipedia.org
, wikipedia.org
(错误代码:ssl_error_bad_cert_dom ain)
² 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的URL(TLD后加点)重定向为与PQDN等效的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!