修复域错误:强制使用 HTTPS,但放置了错误的域,现在它没有改变

修复域错误:强制使用 HTTPS,但放置了错误的域,现在它没有改变

我强制我的网站域名具有https,我使用了这个代码并添加到.htaccess

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://domains.co/$1 [R=301,L]

除了此代码之外,该代码上方还有以下代码:

RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteRule ^(.*)index.php$ /$1 [R=301,L] 

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Options +FollowSymLinks
# RewriteEngine on
RewriteCond %{HTTP_HOST} ^domains.co[nc]
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteRule ^(.*)$ https://ww/w.domains.co/$1 [r=301,nc]

但是正如您在我添加的第一个代码中所看到的,我使用了http/s://domains.co/$1不正确的域domain.com,当我运行该站点时,它会导致错误,因为它使用了错误的域。

之后,我尝试将域名更改为正确的域名,domain.com但它并没有改变。

每次我访问 domain.com 时,它总是直接转到 domains.co

如何解决这个问题?

答案1

我最近也遇到了类似的问题,等了几个小时才解决,可能是因为浏览器缓存重定向 301。

尝试清除缓存。打开 DevTools(按 F12)
在“网络”选项卡上选中“禁用缓存”复选框
保持 DevTools 打开并重新加载页面(按 F5)

相关内容