301重定向一切,新网站的根/整个网站,包括子页面?永久移动 [英] 301 redirect everything to new website root/whole site including sub pages? Moved Permanently

查看:409
本文介绍了301重定向一切,新网站的根/整个网站,包括子页面?永久移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速更新

确定到达那里 这是mod_alias中?

  RedirectMatch 301 ^ / http://brightmist.co.uk/
 

我已经添加了这一行的都下code和它似乎工作,但是我的其他目录如的 http://brightmist.co.uk/blog/2013/02/23/manchester-art-gallery-feb-2013 是告诉谷歌这些页面都暂时搬到 - 见 http://www.internetofficer.com/seo - 工具/重定向检查/

这是否意味着我得去正确的,虽然我的网站的方式,并添加重定向​​的口吻?


原题

我有一个新的网站。 我想重定向我所有的旧网站的链接来自 http://artygirl.co.uk 我的新1 http://brightmist.co.uk/

我主要凭借多年的使用主要是在Photoshop,CSS,HTML,Word将preSS经验的设计师,和jQuery但我不知道很多关于类似htaccess文件编辑的东西。我不想把它错了,因为这意味着谷歌排名下降等

有谁知道任何脚本,我可以粘贴到我的htaccess文件的底部,我想它重定向所有链接/在网站上相同的位置之前的页面。例如,如果我输入 http://artygirl.co.uk/buy-art-prints -cheshire / 我想它去 http://brightmist.co .UK /购买先进的印痕 - 柴郡/我使用的是同一台主机,他们刚刚重新指向域

在其他方面我的主人最近增加了以下code,我想这也是做域映射,同时这里是我的整个htaccess的文件 -

 的ErrorDocument 401 /forms/401.html
ErrorDocument的403 /forms/403.html

RewriteEngine叙述上
的RewriteBase /

#uploaded文件
重写规则^(。* /)?文件/ $的index.php [L]
的RewriteCond%{REQUEST_URI}!*的wp-content /插件。*
重写规则^(。* /)?文件/(.*)WP-包括/ MS-files.php?文件= $ 2 [L]

#添加斜线到/可湿性粉剂管理员
的RewriteCond%{REQUEST_URI} ^ * / WP-ADMIN $
重写规则^(。+)$ $ 1 / [R = 301,L]

的RewriteCond%{} REQUEST_FILENAME -f [OR]
的RewriteCond%{} REQUEST_FILENAME -d
重写规则。 -  [L]
重写规则^([_ 0-9A-ZA-Z  - ] + /)(WP  - 。*)?$ 2 [L]
重写规则^([_ 0-9A-ZA-Z  - ] + /)?(。* \ PHP)$ $ 2 [L]
重写规则。的index.php [L]

< IfModule mod_security.c>
<文件异步upload.php的>
SecFilterEngine关闭
SecFilterScanPOST关闭
< /文件>
< / IfModule>

<文件403.shtml>
为了允许,拒绝
允许所有
< /文件>

从218.143.4.127否认
从143.90.221.204否认
来自95.135.78.190否认
从114.108.150.74否认
从95.135.111.205否认
从91.124.239.150否认
从94.178.2.93否认
从91.124.206.118否认
从91.124.226.116否认
从118.98.32.34否认
从94.180.252.133否认
从58.27.140.58否认
从77.93.197.83否认
从88.191.63.27否认

#盗链保护开始#

RewriteEngine叙述上
的RewriteCond%{HTTP_REFERER}!^ $
的RewriteCond%{HTTP_REFERER} ^ HTTP(S):??//(WWW \)brightmist.co.uk [NC]
的RewriteCond%{HTTP_REFERER} ^ HTTP(S):??//(WWW \)google.com [NC]
重写规则\。(JPG | JPEG | PNG | GIF)$  -  [NC,F,L]

#盗链保护END#
 

解决方案
  

我想从重定向我以前所有的网站的链接的 http://artygirl.co.uk/ 以我的新的 http://brightmist.co.uk/

有几种方法可以做到这一点,所有的人都应该在一个.htaccess文件来实施 http://artygirl.co.uk/ 根目录。

有没有需要检查传入的域名,因为它必须是 artygirl.co.uk ,其中.htaccess文件所在的位置。

要使用下列任一选项,复制并粘贴相应的指令或规则集为一体的的.htaccess文件中的 http://artygirl.co.uk 根目录下。


最快的国家之一是使用简单的重定向一个 mod_alias中指令:

 重定向301 / http://brightmist.co.uk/
 

在输入URL的路径将被自动添加到重定向的URL。


要重定向使用另一个 mod_alias中指令只有特定的路径:

  RedirectMatch 301 ^ /(。*)http://brightmist.co.uk/$1
 

虽然这个例子重定向的一切,正则表达式 ^ /(。*)可修改为只有特定的URL路径图案相匹配。


要重定向使用的mod_rewrite 指令只有特定的路径:

 选项+了FollowSymLinks -MultiViews
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)http://brightmist.co.uk/$1 [R = 301,NC,QSA,L]
 

由于在previous选择,虽然此规则集重定向一切,正则表达式 ^(。*)可修改为只匹配特定的URL路径格局。


注意

  • 相同的目录结构和文件中的 http://artygirl.co.uk/ 必须存在于的http:// brightmist .co.uk / 对于任何previous选择工作。

  • 如果你的问题实际的.htaccess文件正常工作,你可以在 http://brightmist.co.uk/ 根目录下使用新的WP安装。可能需要一些修改,但。

  • 要移动或复制WP安装,检查此链接更改站点网址


更新:

从这些句子在您的评论这个答案:的我的域名都指向同一目录... 的和 ...现在,它创建了一个循环... 的,也许问题是关于域名指向同一个内容(网站),通常被称为域。

如果是那样的话,我不是在.htaccess中的主域名停放1确保重定向是正确的做法只是为了改变浏览器的地址栏中的域名。

不过,从理论上讲是这样的使用mod_rewrite指令应该这样做:

 选项+了FollowSymLinks -MultiViews
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{HTTP_HOST} artygirl \ .CO \ .UK [NC]
重写规则^(。*)http://brightmist.co.uk/$1 [R = 301,NC,QSA,L]
 

永久重定向从 http://artygirl.co.uk http://brightmist.co.uk ,添加完整的传入路径和查询时,present。

由于.htaccess文件也是共享的,我觉得这个规则集应放置在问题的.htaccess文件的顶部,替换以下行:

  RewriteEngine叙述上
的RewriteBase /
 

QUICK UPDATE

Ok getting there Is this mod_alias?

RedirectMatch 301 ^/ http://brightmist.co.uk/

I've added this one line of code underneath everything and it appears to work, however my other directories such as http://brightmist.co.uk/blog/2013/02/23/manchester-art-gallery-feb-2013 are telling google these pages have temporarily moved - see http://www.internetofficer.com/seo-tool/redirect-check/

Does this mean I have to go right the way though my site and add a tone of redirects?


ORIGINAL QUESTION

I have a new website. I'd like to redirect all of my old site links from http://artygirl.co.uk to my new one http://brightmist.co.uk/

I'm primarily a designer with years of experience using mainly in Photoshop, CSS, HTML, Wordpress, and jQuery but I don't know much about editing things like the htaccess file. And I don't want to get it wrong as it means google ranking drops etc

Does anyone know of any script I can paste into the bottom of my htaccess file, I'd like it to redirect all links/pages on the site to the same place as before. For example if I type http://artygirl.co.uk/buy-art-prints-cheshire/ I want it to go to http://brightmist.co.uk/buy-art-prints-cheshire/ I'm using the same host, they've just re-pointed the domain

Among other things my host has recently added the following code, I assume this is also to do with the domain mapping, also here is my whole htaccess file -

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 #

解决方案

I'd like to redirect all of my old site links from http://artygirl.co.uk/ to my new one http://brightmist.co.uk/

There are several ways to achieve that, all of them should be implemented in one .htaccess file in http://artygirl.co.uk/ root directory.

There is no need to check for the incoming domain as it must be artygirl.co.uk, where the .htaccess file is located.

To use any of the following options, copy-paste the corresponding directive or rule-set into one empty .htaccess file in http://artygirl.co.uk root directory.


The fastest one is a simple Redirect using one mod_alias directive:

Redirect 301 /  http://brightmist.co.uk/

Any path in the incoming URL will be appended automatically to the redirected URL.


To redirect only certain paths using another mod_alias directive:

RedirectMatch 301 ^/(.*)  http://brightmist.co.uk/$1

Although this example redirects everything, the regex ^/(.*) can be modified to match only certain URL-path pattern.


To redirect only certain paths using mod_rewrite directives:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)   http://brightmist.co.uk/$1  [R=301,NC,QSA,L]

As in the previous option, although this rule-set redirects everything, the regex ^(.*) can be modified to match only certain URL-path pattern.


NOTES

  • The same directory structure and files in http://artygirl.co.uk/ must exist in http://brightmist.co.uk/ for any of the previous options to work.

  • If the actual .htaccess file in your question works as expected, you could use it in http://brightmist.co.uk/ root directory where the new WP is installed. Might require some modifications, though.

  • To move or copy a WP install, check this link Changing the site URL.


UPDATE:

From these sentences in your comment to this answer: "My domains both point at the same directory..." and "...now it creates a loop...", maybe the question is about domains pointing to the same content (Website), normally known as parked domains.

If that's the case, I am not sure redirecting in .htaccess the primary domain to the parked one is the correct approach just to change the domain name in the browser's address bar.

However, in theory something like this should do it using mod_rewrite directives:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST}  artygirl\.co\.uk      [NC]
RewriteRule ^(.*)   http://brightmist.co.uk/$1  [R=301,NC,QSA,L]

Redirects permanently any request from http://artygirl.co.uk to http://brightmist.co.uk, appending the complete incoming path and query when present.

Since the .htaccess file is also shared, I think this rule-set should be placed at the top of the .htaccess file in the question, replacing the following lines:

RewriteEngine On
RewriteBase /

这篇关于301重定向一切,新网站的根/整个网站,包括子页面?永久移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆