简体   繁体   中英

.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.

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.

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

Basically I want to redirect my users from videohost url to a search form on my main site itself.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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