简体   繁体   English

.htaccess将url.com/file.php?=$terms重定向到newurl.com/search.php?= $ terms(如果引荐来源网址不是site.com)

[英].htaccess redirect url.com/file.php?=$terms to newurl.com/search.php?=$terms if referrer is not site.com

I have 2 video sites, one of them is a video host ( url.com ) and another is a wordpress frontend ( newurl.com ) where I embed videos from my video host. 我有2个视频站点,其中一个是视频主机( url.com ),另一个是wordpress前端( newurl.com ),我在其中嵌入了视频主机中的视频。

What I want to do is disable any access to the content of the video host except my main site being able to still embed files. 我想要做的是禁用对视频主机内容的任何访问,但我的主站点仍然能够嵌入文件。

I thought of doing it via using htaccess and using rule to allow access only if reffer is newurl.com else if there is no referrer or something else. 我想通过使用htaccess和使用rule来做到这一点,只有在reffer为newurl.com时才允许访问,否则,如果没有引荐来源网址或其他内容,则允许访问。

But problem is the video embed shows related videos within the video player of the embed and thats from where the users get link to the video host. 但是问题在于视频嵌入会在嵌入的视频播放器中显示相关视频,并且多数民众赞成从中获得与视频主机的链接。

I want to do something like this. 我想做这样的事情。

When a user clicks a related video, he is redirected to something like this: 当用户点击相关视频时,他将被重定向到以下内容:

url.com/player/cbplayer/plugins/related/related_videos.php?vid=%%VID ID%%&title=%%VIDEO TITLE%%&tags=%%VIDEO TAGS%%

I want to redirect him to my main site like this 我想像这样将他重定向到我的主站点

newurl.com/search.php?=%%VIDEOTITLE

or if Video title cant be used then atleast the whole string after related_videos.php itself 或者如果无法使用视频标题,则在related_videos.php本身之后至少保留整个字符串

Basically I want to redirect my users from videohost url to a search form on my main site itself. 基本上,我想将用户从videohost网址重定向到主站点本身上的搜索表单。

Also, while using Referrers I want to be safe that it doesnt redirects the embed from my main site content as well 另外,在使用引荐来源网址时,我想确保它不会从我的主要网站内容中重定向嵌入内容

The embed file is called embed.php 嵌入文件称为embed.php

If I am understanding you correctly, this will match all hits on related_videos.php (with a title querystring) but only when referrer is not your.domain and redirect them to thatnewurl.com/search.php?title=oldtitle 如果我理解正确你,这将匹配所有命中related_videos.php (带有标题查询字符串),但只有当引用不your.domain并重定向他们thatnewurl.com/search.php?title=oldtitle

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !your\.domain 
RewriteCond %{QUERY_STRING} (^|&)title=(.*?)(&|$) [NC]
RewriteRule related_videos\.php http://thatnewurl.com/search.php?title=%2

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

相关问题 为什么页面显示内容时浏览到site.com/file.php/ - Why page showing content when browse to site.com/file.php/ 使用htaccess将www.url.com/x=y重定向到www.url.com/file.php?x=y? - Redirect www.url.com/x=y to www.url.com/file.php?x=y with htaccess? 有没有办法创建一个像 site.com/state/127 这样的友好 url 并且仍然指向一个特定的文件,比如 index.php - Is there a way to create a friendly url like site.com/state/127 and still point to a particular file like index.php 从PHP中传递的变量解析出“ site.com”? - Parsing out “site.com” from a passed variable in PHP? 像site.com/#/xyz一样,PHP / CodeIgniter是否可以读取URL? - Any way for PHP/CodeIgniter to read the URL, when it's like site.com/#/xyz …? 如何使用.htaccess url.tld / file.php重定向到url.tld / file.php / - how to redirect with .htaccess url.tld/file.php to url.tld/file.php/ 如何使用此URL格式的$ _GET site.com/extension/rar - how to use $_GET with this url format site.com/extension/rar 需要使用 www.mydomain.com/filename/ 而不是 www.mydomain.com/file.php?id=1 - need to use www.mydomain.com/filename/ instead of www.mydomain.com/file.php?id=1 结合来自url.com和www.url.com的喜欢 - Combining likes from url.com and www.url.com mod_rewrite指向site.com/something到index.php?values = something - mod_rewrite to direct site.com/something to index.php?values=something
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM