• When I attach a pdf or insert an image, the document defaults to include the entire path in the link url. For instance, if my site is dev.mysite.com and I’m working on a post, the attachment will be linked to https://dev.mysite.com/wp-content/uploads/2010/12/mydocument.pdf.
    I end up manually deleting https://dev.mysite.com from the link url so they don’t show up when I link the item from the gallery. I’d rather have the gallery define the link url as /wp-content/uploads/2010/12/mydocument.pdf

    I’m not the only person working on the dev site, and not everyone cares or is going to remember to remove the domain from the gallery link url when uploading files. Sometimes I forget too.

    The fault is compounded when people start inserting gallery items into a post or page because I then have to go through and make sure the urls in my content consistently lack the domain as well.

    Why is this important? Because when I move my database and its attachments at /wp-content/uploads/... from https://dev.mysite.comtohttps://www.mylivesite.com` all the attachment links in posts break.

    This frustrates me no end. Please – PLEASE tell me there is a simple setting somewhere in wordpress that will allow me to define attachments with short urls not including domain names. I’m not seeing it.

    I will be grateful for any assistance with this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Such a setting would be nice indeed, but until there is one, you could use a MySQL statement like:

    update wp_posts set post_content=replace(post_content,'https://dev.mysite.com/wp-content/uploads/','https://www.mylivesite.com/wp-content/uploads/');

    See also, Moving wordpress blog to new place and new domain [hostingformula.net]

    gr33nman

    This isn’t an answer to your question, but another question about how you’re doing what you mention in your post.

    I am also going to be moving my site from dev to live, and wanted to minimize broken links. I was told I could remove the domain name from the link url, and that would overcome the problem. However, when I do that, clicking on that link ends up going to a blank page with the url (using your example above) https://dev.mysite/wp-content/. In other words, going to the directory, but not to the document.

    I’d appreciate knowing your process, specifically when and where do you manually delete the domain name from the link.

    Thanks,
    Marcia

    Thread Starter gr33nman

    (@gr33nman)

    @wlindley, sorry – I didn’t see your reply until now. This is exactly what I shall have to do.

    @mbolsinga, Don’t forget to copy all your images from dev.mysite.com/wp-content/uploads/ to https://www.mysite.com/wp-content/uploads/.

    Once that’s achieved, you still have to go through the process of changing the urls in the raw sql using either wlindley’s suggestion or process the post_content column using a text editor that can handle search and replace to change ‘href=”https://dev.mysite.com/’ to ‘/’. This has the effect of changing it so it’s web root, but not tied to a particular domain. The only problem is that afterwards, WordPress is still going to add the full domain to any new links for users who are too busy to manually remove the full domain themselves.

    Unfortunately at current, the problem remains unsolved.

    Uploaded documents really should be universal web root “/wp-content/uploads/whatever.gif”, etc. The current method needs revision.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Full paths in attachments hamper data transfer from dev to live sites’ is closed to new replies.