子域未更改: 洛哈
旧域: loja。 churrascoelareira.com.br
新域 loja。 bomdebrasa.com
问题是google仍在将访问者发送到如下网址: loja.churrascoelareira.com.br/exemple-product-page.html
如何将其转发给: loja.bomdebrasa.com/exemple-product-page.html
带有通配符?
EDIT1 : 该文件类似于以下内容(两个域都指向同一台服务器),并且该文件位于以下两个文件夹中(仅用于确保):public_html和public_html / churrascoelareira.com.br
在此代码下有一个cPanel托管域的图像。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ $1.php [L]
# Google Analytics Integration - Added by cPanel.
<IfModule mod_substitute.c>
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|(<script src='/google_analytics_auto.js'></script>)?</head>|<script src='/google_analytics_auto.js'></script></head>|i"
</IfModule>
# END Google Analytics Integration
RewriteCond %{HTTP_HOST} ^bomdebrasa\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.bomdebrasa\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/www\.bomdebrasa\.com\/newsite\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^bomdebrasa\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.bomdebrasa\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^site\/?$ "http\:\/\/bomdebrasa\.com\/newsite" [R=301,L]
RewriteCond %{HTTP_HOST} ^bomdebrasa\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.bomdebrasa\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^site\/produtos$ "http\:\/\/bomdebrasa\.com\/newsite" [R=301,L]
RewriteCond %{HTTP_HOST} ^loja\.churrascoelareira\.com\.br$
RewriteRule ^/?(.*)$ https://loja.bomdebrasa.com/$1 [R=301,QSA]
# php -- BEGIN cPanel-generated handler, do not edit
# NOTE this account's php is controlled via FPM and the vhost, this is a place holder.
# Do not edit. This next line is to support the cPanel php wrapper (php_cli).
# AddType application/x-httpd-ea-php56 .php .phtml
# php -- END cPanel-generated handler, do not edit
EDIT2 : 我终于找到使用通配符进行重定向的位置(在此过时的cPanel版本中)。这样就解决了(不是通过手动创建文件,而是解决了),我检查了已经存在的.htaccess文件,没有发现新内容,所以我猜想它是用另一种方式完成的。
答案 0 :(得分:2)
不确定此处的“通配符”是什么意思,但是如果 old http主机中有此请求,则此规则设置应将这些请求转发至新域:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^loja\.churrascoelareira\.com\.br$
RewriteRule ^/?(.*)$ https://loja.bomdebrasa.com/$1 [R=301,QSA]
要使其正常工作,您显然需要启用重写模块并在旧的http主机中加载 。该规则集将在http服务器的主机配置中或在动态配置文件(“ .htaccess”)中同样起作用,但是,您应该首选第一个选项。如果您决定使用动态配置文件,请注意已为旧的http主机启用了解释功能,并且该文件位于主机的DOCUMENT_ROOT
文件夹中,并且可由http服务器进程读取。