When working on a project, I would like to use the online images, so I don't have to download e.g. all images (as described here).
To achieve this, I wrote a view lines in my .htaccess-file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 8890
RewriteRule ^wp/media/.+ https://www.example.com:443%{REQUEST_URI}
</IfModule>
According to htaccess.madewithlove.be this should convert an image url from:
https://example.localhost:8890/wp/media/27442.jpg
to:
https://www.example.com/wp/media/27442.jpg
Context:
- MacBook Pro
- OS X Catalina 10.15.2
- MAMP Pro 5.5.1
- WordPress 5.3.2
- example.localhost:8890 (SSL) up and running
- local website is working fine
What I already tried/verified/adjusted:
- How to get htaccess to work on MAMP
- mamp pro htaccess rewriteRule not working
- https://wordpress.stackexchange.com/questions/346778/rewrite-rule-to-load-images-from-production-does-nothing?rq=1
- The
.htaccessis being executed. When entering garbage, I got a error 500 - Changed
httpd.confaccordingly
Am I missing something? What else could prevent this from working?
The problem was that I had another
.htaccess-file inside thewp-folder, because I moved the WordPress installation into its own directory (see here). When moving the rules into this inner.htaccess-file, it started working immediately.