我强迫我的站点域拥有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
如何解决这个问题?
我最近遇到了类似的问题,我等了几个小时就解决了,可能是因为浏览器缓存了重定向 301。
尝试清除缓存。在“网络”选项卡上打开您的 DevTools(按 F12)
选中“禁用缓存”复选框
保持 DevTools 打开并重新加载页面(按 F5)