谷歌搜索结果将我的页面显示为(ip)/mypage.html而不是https://www.mydomain.com/mypage.html。我认为解决方案是将ip重定向到域名。我已经找到了很多非常相似的方法来做这件事,但它们都不适合我。我有一个将http重定向到https的现有规则。这是我的.htaccess文件当前的样子:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]我做错了什么?
发布于 2012-04-04 23:05:45
您的两个重写条件冲突。它们要求http_host为11.11.11.111并同时为*.mydomain.com。只需添加一个或类似于:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^11\.11\.11\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]发布于 2014-06-20 22:09:02
RewriteEngine on
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]将"111“更改为您的IP
发布于 2020-11-25 16:22:35
更新威廉的答案。您只需要替换此代码片段中的域名(your-domain.io)。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$
RewriteRule (.*) https://your-domain.io/$1 [R=301,L]https://stackoverflow.com/questions/9985735
复制相似问题