当我设置子域时,我错误地创建了一些链接。现在Google认为我的子域和根域都有一些页面。我需要修复这个问题,但是我不能重定向整个子域。
我想要做的事情的例子:
https://sub.example.com/ (no redirect)
https://sub.example.com/keep-1 (no redirect)
https://sub.example.com/keep-2 (no redirect)
https://sub.example.com/move-1/* => https://example.com/move-1/*
https://sub.example.com/move-2/* => https://example.com/move-2/*我已经尝试过许多.htaccess解决方案,而且我已经接近了,但是我想不出答案。以下是我尝试过的:
尝试#1 -正确重定向,但不作为解决方案,因为它从子域重定向所有东西
RewriteCond %{HTTP_HOST} ^sub\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301,NE]尝试2-没有重定向任何东西-似乎是正确的解决方案,但我错过了一些关于如何重定向工作,我认为.
RewriteCond %{HTTP_HOST} ^sub\.example\.com/move-1/ [NC]
RewriteRule ^(.*)$ https://example.com/move-1/$1 [L,R=301,NE]第三次尝试-不会重定向任何东西
RewriteCond %{HTTP_HOST} ^sub\.example\.com/move-1/(.*)$ [NC]
RewriteRule https://example.com/move-1/$1 [L,R=301,NE]尝试#4 -不会重定向任何东西
RewriteBase /
RewriteRule ^sub\.example\.com/move-1/(.*)$ https://example.com/move-1/$1 [R=301]我的.htaccess文件位于根域的根html文件夹中,并且似乎有控制权。我也尝试过从子域的根文件夹,但这没有重定向任何东西。
发布于 2018-01-04 17:35:58
RewriteCond %{HTTP_HOST} ^sub\.example\.com$
RewriteRule ^move(.*) https://example.com/move$1 [R=301,L]%{HTTP_HOST}是主机名,映射到域(如sub.example.com或example.com )。它不包含域后面的任何path部件。$1是反向引用,映射到regex部件(.*)。RewriteRule告诉请求uri模式是否以/move开头,然后永久地重定向到https://example.com/move$1。
https://stackoverflow.com/questions/48100472
复制相似问题