Reputation: 103
Hello im having a problem with images in my wordpress directory with a plug-in that doesnt have much support, i've fixed most bits but the images. I know would have to alter my .htaccess in the root but im not sure how.
Heres what my current .htaccess looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
My site doesnt load up the images in the plugin, when inspecting the sourcecode on chrome its looking for an image at the following URL, which gives a 404 error.
The correct URL for the image would be:
http://www.example.com/wp-content/plugins/wprx/wpt_image.php?i=/wp-content/wpt_cache/7/1713/01.jpg
any ideas on altering the .htaccess to remove the "http://www.example.com//" from the start of the URL?
Many Thanks, Pete
Upvotes: 2
Views: 1738
Reputation: 786091
You can have your htaccess like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# fix images path
RewriteCond %{REQUEST_URI} (http://.+?\.(?:jpe?g|gif|bmp|png))$ [NC]
RewriteRule ^ %1 [L,R=301,NE]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Upvotes: 0
Reputation: 23890
While what you're asking is possible, you should not choose this solution, but instead find and resolve the cause of your problem.
Because the browser will still be looking for
http://www.example.com//http://www.example.com/wp-content/plugins/wprx/wpt_image.php?i=/wp-content/wpt_cache/7/1713/01.jpg
after this, you will only provide it with a file then.
In the path passed to the .htaccess file, the protocol, host and port have already been stripped, leaving you with
//http://www.example.com/wp-content/plugins/wprx/wpt_image.php?i=/wp-content/wpt_cache/7/1713/01.jpg
so you really want to remove the second http://www.example.com
.
Putting the following line right after RewriteBase
should make it kind of work:
RewriteRule ^//http://www.example.com/(.*)$ /$1
Upvotes: 2