网络营销电子商务研究中心  
USA Web Hosting Direct
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > Linux
User Name
Password
 
FAQ Members List Calendar 域名注册 PHP Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1   IP: 23.81.143.15
Old 2018-01-25, 11:16 PM
Radcliff Radcliff is offline
初级会员
 
Join Date: 2014-03-02
Posts: 1
Radcliff 现在声名狼藉
Default .htaccess to redirect jpg to a webpage

With my site, I have www.mysite.com/images/1.jpg and www.mysite.com/pixels/1.jpg

I would like for the .htaccess to redirect ANY jpg (just jpgs) image throughout my entire website to redirect to www.mysite.com/directory/

I had a .htaccess file that did this, but then I couldn't use the image on my own website like it would just be a blank box but if I visited the exact url of the image, it took me to www.mysite.com/directory/

The reason for this is like if someone finds the images of mine on Google Images or on Tumblr or another website, once they click the image and visit the url of the image on my site, it will redirect them to a directory like www.mysite.com/directory/

I hope I explained this well enough.
Reply With Quote
  #2   IP: 23.81.143.15
Old 2018-01-25, 11:17 PM
Ravenswood Ravenswood is offline
初级会员
 
Join Date: 2014-01-12
Posts: 3
Ravenswood 现在声名狼藉
Default

I gather you want to check the referer. It's one of the HTTP request headers that tells the webserver what URL they were at that referred them to what they're requesting. Also keep in mind that referers can be forged. You can add these rules to the htaccess file in your document root:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com/ [NC]
RewriteRule \.jpg$ /directory/ [L,R=302.NC]
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to force SSL with .htaccess Union Grove 服务器环境搭建 0 2017-09-18 09:58 PM
.htaccess 301 Redirect Packard 建站交流 1 2014-06-15 08:53 PM
FIX - Vbulletin redirecting to filestore72.info / url123.info etc - Redirect Google Mabton vBulletin技术交流 0 2014-05-31 07:55 AM
htaccess 301 redirect tutorial yahoo 服务器环境搭建 0 2009-09-06 01:45 AM
301 Redirect 永久重定向的实现 yahoo 搜索引擎优化 0 2008-01-21 12:51 AM

Prescription-glasses.com offers prescription glasses online at discount prices.
所有时间均为 +8. 现在的时间是 09:21 PM, Free Patent & Patent Ideas