url重定向到外部站点中的页面 [英] url redirect to page in external site

查看:279
本文介绍了url重定向到外部站点中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站中有一个页面A
http://www.siteA.com /1987/title.html

i have a page in my siteA http://www.siteA.com/1987/title.html

我想将页面上方的301重定向到外部站点siteB中的页面,如
http://www.siteB.com/page/title3.html

i want to 301 redirect above page to a page in external site siteB as shown in example below http://www.siteB.com/page/title3.html

我想在htacess中执行此操作,而不是在php中

I want to do this in htacess, not in php

我尝试过

#redirect 301 /1987/title.html http://www.siteB.com/page/title3.html

这似乎对我不起作用

推荐答案

启用mod_rewrite并.htaccess通过 httpd.conf ,然后将此代码放在 DOCUMENT_ROOT <下的 .htaccess 中/ code>目录:

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.siteA\.com$ [NC]
RewriteRule ^1987/title\.html$ http://www.siteB.com/page/title3.html [L,R=301,NC]

这篇关于url重定向到外部站点中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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