Forum Moderators: phranque

Message Too Old, No Replies

Redirect to do for localhost

         

agneslesage

2:06 pm on May 25, 2011 (gmt 0)

10+ Year Member



Hello

I am on wordpress, and using a plugin that unfoirtunately writes absolute URLs for images.
As I move sites and DB across several domains, I'"d like to find a fix.
So instead of having
http://localhost/my-site.com/wp-content/uploads/myfile.jpg

in the database, I manage to get it be just
/wp-content/uploads/myfile.jpg

And that works for any domain I use outside, as it goes to root.
However, it does not work more on my localhost.

So i tried to have a redirect rule in my local.htacess, that would redirect anything starting with /wp-content" to "http://localhost/mysite.com/wp-content"

After several trials resulting in server errors or messing up other things on my site, this one seems ok:

RewriteRule ^/wp-content/?$ http://localhost/mysite.com/wp-content [R=301,QSA,L]


But does not work...
When I look at the code of my page, the image is still called with src="/wp-content/uploads/" so it does n,ot show up.
I must be doind sthg wroing with the wildcards.

Any help?
Thanks
Agnes

g1smd

9:09 pm on May 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What is the image URL shown in the link on the page?

What is the actual location of the image (i.e. internal filepath) where the image resides?

agneslesage

7:05 am on May 26, 2011 (gmt 0)

10+ Year Member



If the image is on:
http://localhost/my-site.com/wp-content/uploads/myfile.jpg 

and the path stored in the DB, in order to avoid moving problems, is:
/wp-content/uploads/myfile.jpg 

The path that shows in the source of the page (when the image does not show is still:
img src="/wp-content/uploads/myfile.jpg"

where it should include the host:
http://localhost/my-site.com/wp-content/uploads/myfile.jpg 

So the .hjtaccess should redirect anyhthing starting with "/wp-content" tpo "http://localhost/mysiite.com/wp-content" but of course not mess up with all other rferences that only include "wp-content"
Thanks
Agnes

agneslesage

7:05 am on May 26, 2011 (gmt 0)

10+ Year Member



If the image is on:
http://localhost/my-site.com/wp-content/uploads/myfile.jpg 

and the path stored in the DB, in order to avoid moving problems, is:
/wp-content/uploads/myfile.jpg 

The path that shows in the source of the page (when the image does not show is still:
img src="/wp-content/uploads/myfile.jpg"

where it should include the host:
http://localhost/my-site.com/wp-content/uploads/myfile.jpg 


So the .htaccess should redirect anyhthing starting with "
/wp-content
" tpo "
http://localhost/mysiite.com/wp-content
" but of course not mess up with all other references that only include "
wp-content
"

Thanks
Agnes