简体   繁体   English

将特定页面重定向到另一个页面和域

[英]Redirect a Specific Page to another Page and Domain

I have a website script that installed on the server and pointed to several domains. 我有一个安装在服务器上并指向多个域的网站脚本。 Sometimes I need to redirect a specific page to another site and for now, I use Cloudflare feature to redirect the page but there limit for a free plan user. 有时我需要将特定页面重定向到另一个站点,现在,我使用Cloudflare功能重定向页面,但是对于免费计划用户有限制。 So, I want to know how to redirect the specific page on a specific domain using .htaccess, PHP, or etc? 所以,我想知道如何使用.htaccess,PHP等重定向特定域上的特定页面?

For example, I have content /blabla on first.com and second.com , Then I want to redirect a page first.com/blabla to third.com/target but not on second.com/blabla , both of domain have the same IP and content is in the same folder. 例如,我在first.comsecond.com上有内容/blabla ,然后我想将页面first.com/blabla重定向到third.com/target而不是second.com/blabla ,两个域都有相同的IP和内容位于同一文件夹中。

Thanks 谢谢

Redirect in php: 在PHP中重定向:

<?php header('Location: '. $newURL); ?>

Redirect in javascript: 在javascript中重定向:

<script>window.location.href = "newurlhere";</script>

This should work for you. 这应该适合你。

RewriteEngine on


RewriteCond %{HTTP_HOST} ^(www\.)?first\.com$ [NC]
RewriteRule ^/?blabla http://third.com/something [L,R]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM