简体   繁体   中英

htaccess to redirect all referrers except one

I have been trying to write an htaccess file for awhile now with no luck.

so I need to redirect everyone away from my site unless they are coming from a specific URL.

So only if the referrer is from lets say www.yahoo.com will it go through otherwise it will get redirected.

It needs to match the root domain so if the referrer is www.yahoo.com/somedirectory or www.yahoo.com/?someparam=someparamvalue&etcetc=etcetc

it should get passed through and NOT redirected.

Could anyone help me please.

Thank You!

Try:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://www\.yahoo\.com/
RewriteRule ^ /wrong-referer-url? [L,R]

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