Search code examples
php.htaccessmod-rewriteurl-rewritingmode

how to show fake directory using htaccess for image folder


I have a image folder and it has images uploaded by users in my website.

The image path was show like this in source code

/wp-content/uploads/1/49485_thumbnail.jpg
/wp-content/uploads/422/49480_thumbnail.jpg

I want to show like it was inside the fake folder "images"

/images/1/49485_thumbnail.jpg
/images/422/49480_thumbnail.jpg

Help me to create the RewriteRule to do this.


Solution

  • You can use the .htaccess directory redirect:

    RewriteEngine On
    RewriteRule ^images/(.*)$ /wp-content/uploads/$1 [QSA,L]