0

I'm developing a WordPress multisite locally and I'm wanting to redirect the broken 404 images to the production site rather than having to download them all.

I currently have:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-d [OR]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_URI} ^/files/[^\/]*/?.*$
 RewriteRule ^(.*)$ http:/live-domain.com/$1 [QSA,L]
</IfModule>

Which works great for the images which were 404ing and I don't have locally.

However for some reason it seems to also be trying to redirect the images which I've added locally to the production domain.

So for example:

http://localhost/files/broken-image/ -> http:/live-domain.com/files/broken image works great

But http://localhost/files/working-image tries to redirect to http://live-domain.com/files/working-image which 404s.

So I'm ending up with the reverse problem.

I thought

 RewriteCond %{REQUEST_FILENAME} !-d [OR]
 RewriteCond %{REQUEST_FILENAME} !-f

Should handle this though and ignore images which aren't 404ing?

Am I missing something here?

Many thanks

2
  • Are you using the code in htaccess or in a server config file?
    – Amit Verma
    Oct 18, 2018 at 17:20
  • Hey @starkeen this is in a .htaccess file before all the other rules. cheers Oct 18, 2018 at 17:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.