【发布时间】:2013-02-16 12:55:21
【问题描述】:
快速更新
好的,到了 这是 mod_alias 吗?
RedirectMatch 301 ^/ http://brightmist.co.uk/
我已在所有内容下方添加了这一行代码,它似乎可以工作,但是我的其他目录(例如 http://brightmist.co.uk/blog/2013/02/23/manchester-art-gallery-feb-2013)告诉谷歌这些页面已暂时移动 - 请参阅 http://www.internetofficer.com/seo-tool/redirect-check/
这是否意味着我必须在我的网站上正确前进并添加重定向语气?
原始问题
我有一个新网站。 我想将我所有的旧网站链接从 http://artygirl.co.uk 重定向到我的新链接 http://brightmist.co.uk/
我主要是一名拥有多年经验的设计师,主要使用 Photoshop、CSS、HTML、Wordpress 和 jQuery,但我对编辑 htaccess 文件之类的东西知之甚少。而且我不想弄错,因为这意味着谷歌排名下降等
有谁知道我可以粘贴到我的 htaccess 文件底部的任何脚本,我希望它将网站上的所有链接/页面重定向到与以前相同的位置。例如,如果我输入 http://artygirl.co.uk/buy-art-prints-cheshire/ 我希望它转到 http://brightmist.co.uk/buy-art-prints-cheshire/ 我使用的是同一个主机,他们只是重新指向了域
除此之外,我的主机最近添加了以下代码,我认为这也与域映射有关,这也是我的整个 htaccess 文件 -
ErrorDocument 401 /forms/401.html
ErrorDocument 403 /forms/403.html
RewriteEngine On
RewriteBase /
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 218.143.4.127
deny from 143.90.221.204
deny from 95.135.78.190
deny from 114.108.150.74
deny from 95.135.111.205
deny from 91.124.239.150
deny from 94.178.2.93
deny from 91.124.206.118
deny from 91.124.226.116
deny from 118.98.32.34
deny from 94.180.252.133
deny from 58.27.140.58
deny from 77.93.197.83
deny from 88.191.63.27
# Hotlink Protection START #
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?brightmist.co.uk [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
# Hotlink Protection END #
【问题讨论】:
-
您为什么不尝试在
http://artygirl.co.uk的.hataccess 文件中进行重定向。像这样:Redirect 301 / http://brightmist.co.uk/我看不出使用mod_rewrite的原因,至少不是从你的问题来看,mod_alias更快且易于使用。 -
感谢您的评论。请您进一步解释一下。该站点位于同一主机/位置我想这就是它循环的原因?请您发布完整的代码。我是一名设计师,所以对 htaccess 编码一无所知。
-
不过,这是另一个域。我的建议是在旧站点根目录的 .htaccess 文件中只使用一行。像这样:
Redirect 301 / http://brightmist.co.uk/,这就是您需要将所有内容重定向到http://brightmist.co.uk/,包括 URL 路径和查询。当然,在新站点中,旧的目录结构和文件必须存在。 -
不,抱歉,主机已重命名为brightmist.co.uk,artygirl.co.uk 已映射/重定向到这个新主机brightmist.co.uk。我的 301 工作正常(见下面的答案),但它没有重定向所有链接?我可以添加一些 htaccess 代码吗?
-
这正是我要说的。尝试使用
mod_alias(在我的评论中)而不是mod_rewrite(在你的答案中)。它要快得多。是的,谷歌将赶上永久重定向 (301)。
标签: .htaccess redirect mod-rewrite http-status-code-301