How to hide original image path using .htaccess?

Member

by rollin , in category: Third Party Scripts , 4 months ago

How to hide original image path using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elise_daugherty , 4 months ago

@rollin 

To hide the original image path using .htaccess, you can use the RewriteRule directive to rewrite the image requests to a different path. Here is an example of how you can achieve this:

  1. Create a directory in your web server where you will store the images that you want to hide the original path for.
  2. Add the following code to your .htaccess file in the directory where the original images are located:
1
2
RewriteEngine On
RewriteRule ^(.+).(jpg|png|gif)$ /path/to/hidden/images/$1.$2 [L]


Replace "/path/to/hidden/images/" with the actual path to the directory where you want to store the hidden images. This rule will rewrite requests for image files (jpg, png, or gif) to the specified hidden directory.

  1. Upload the original images to the hidden directory that you specified in the RewriteRule.
  2. When linking to the images on your website, use the rewritten path instead of the original path. For example, if the original image path is "/images/image.jpg", you would link to it as "/path/to/hidden/images/image.jpg".


By following these steps, you can hide the original image path using .htaccess and serve the images from a hidden directory on your server.