How to rewrite WordPress uploads folder to another folder using htaccess

I found that the following code online could be used to spoof the WordPress uploads folder, rewriting URLs to a different folder on the server:

# BEGIN Spoof wp-content/uploads directory
RedirectMatch 301 ^/uploads/(.*)$ https?://yoursite.com/wp-content/uploads/$1
# END Spoof wp-content/uploads directory

It is my understanding that under Media settings page the ‘Full Path to files’ needs to point to desired spoof folder.

Read More

I have tried using the above code but WordPress throws a error 404. My uploads are set to be organized by year and month. The file was that uploaded and tested indeed exists on the server.

Here is an example of the structure setup:

Real folder path -> http://yoursite.com/wp-content/uploads/2011/09/icon.jpg
Spoofed folder path -> http://yoursite.com/uploads/2011/09/icon.jpg

My question: Is there anything wrong with the rewrite code that could lead to the error 404 issue?

Related posts

Leave a Reply

1 comment

  1. yes, this:

    https?://yoursite.com
    

    doesn’t do anything you want, just make it http://yoursite.com. Next to that, make sure your server actually supports RedirectMatch.