Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 647787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:45:39+00:00 2026-05-13T21:45:39+00:00

I want to, using htaccess, allow hotlinking BUT if someone views an image on

  • 0

I want to, using htaccess, allow hotlinking BUT if someone views an image on my site I want to redirect them to a “hosted” version of the image where I display my navigation etc.

So essentially anyone hotlinking from an external site will not be affected but if someone views the image on my server directly i.e. http://www.domain.com/image.jpg itll redirect. I also want to make sure I can display images correctly from within my site too.

Can anyone help?

EDIT: Here is the code I currently have

RewriteCond %{REQUEST_FILENAME} \.jpg$
RewriteCond %{HTTP_REFERER} =""
RewriteRule ^userpics/covers/(.*).jpg$ /view/$1.html [R=301]

RewriteRule ^view/(.*).html$ /view.html?img=$1 [L]

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:45:40+00:00Added an answer on May 13, 2026 at 9:45 pm

    Use .htaccess

    RewriteEngine on
    RewriteCond %{REQUEST_URI} \.(jpg|png|gif)$
    RewriteCond %{HTTP_REFERER} ^https?://yoursite\.com/.*$ [NC]
    RewriteRule ([^/]+)$ url_to_script?img=$1
    

    You could simplify

    RewriteCond %{HTTP_REFERER} ^https?://yoursite\.com/.*$ [NC]
    

    to just

    RewriteCond %{HTTP_REFERER} yoursite\.com [NC]
    

    And the rule can be written as

     RewriteRule (.*) url_to_script?img=$1
    

    if you need to include the path to the image in your parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect using .htaccess abc.com/test.php to abc.com/test . but it will execute/display
I want to do permanent redirect using htaccess. For eg :- Redirect permanent /presskit
I want to make this url redirect using .htaccess (linux/apache) .. I want to
I want to Set Favicon for All files in my site using htaccess ??
If you want redirect two separate domains to the same subfolder using .htaccess, you
Possible Duplicate: How to add .php extension using .htaccess url rewriting? I want to
I write this in api v2: map.enableGoogleBar(); I want to using v3, but I
So for security reasons, I want to disallow http://www.domain.com/directory/ but allow that physical directory
i would like to redirect using htaccess to a page that cchecks the query
I want to configure a mod_rewrite rule without using .htaccess files. When I put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.