• Since I restore my online backups to my local host sometimes and it’s important that all links and images work well without having to change anything, I use relative links in my WordPress/ WooCommerce posts instead of absolute links.

    So let’s say the following is a relative image link that I use in one of my posts:

    /wp-content/uploads/image.jpg

    and here is my local host:

    https://127.0.0.1/my-local

    In order for the relative link to work on the local host I need to edit the post and add /my-local/ right before the relative link:

    /my-local/wp-content/uploads/image.jpg

    The problem is, I don’t want to make any changes to posts. is there any hook or filter I can use on my local host to temporarily add /my-local/ right before the relative links so that I can see the images and links without having to replace or change anything ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter worldless

    (@worldless)

    I’ve been looking for a solution over a week and I haven’t found anything yet. I had to use a search and replace plugin for the time being.

    If you guys came up with a better solution please update this post

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get relative links to work in a local host with a sub-directoty ?’ is closed to new replies.