Support » Fixing WordPress » URL discrepancy between localhost and live

  • Resolved pszeinert


    I use a PHP IDE (Eclipse) for quick renderings of my site.

    My local files are stored at http://localhost/problemsit

    My live files are stored at

    The live site is set up as a sub-domain, but can also be typed

    The problem is that when I define images, for example background in the imported CSS files, I can successfully load them using /wp-content/themes/thematic/library/imgs/file.gif

    …however, on my local computer, the files will not resolve unless I absolutely link it as http://localhost/problemsite/wp-content/themes/thematic/library/imgs/file.gif

    I have tried any number of periods before the file and have scoured many sites before coming here. I even tried adding this snippet:

    define('WP_HOME', 'http://'.$_SERVER['HTTP_HOST'].'/problemsite');
    define('WP_SITEURL', 'http://'.$_SERVER['HTTP_HOST'].'/problemsite');

    to the wp-config.php file, but to no avail.

    This is the first problem I have encountered that I have not been able to find a resolution for.

    Re-formatted post for clarity

Viewing 4 replies - 1 through 4 (of 4 total)
  • Do not use relative urls in a WordPress install. Stick to full, absolute, urls.

    Do not use relative urls in a WordPress install. Stick to full, absolute, urls.

    That would explain my trouble finding a solution. After researching the logic behind using absolute URLs, I understand and completely agree.

    For a follow up question, is there a bit of PHP such as an “if” statement that could swap strings depending on the location of the files?

    i.e. http://localhost/problemsite vs.

    Not that I know of but you could have a look at the Search & Replace plugin:

    Yeah, search and replace is what I have done in the past. I would like to keep up to date copies on both my testing server and live server. Ideally, they would be two identical code bases in two different locations.

    I guess I can consider this resolved, but I will post a solution if I can develop one. To be honest, I think I have used a similar statement for another project.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘URL discrepancy between localhost and live’ is closed to new replies.