We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45638
    • 3 Posts
    Hello!

    What and where should I do to change site's url's after moving it from internet to localhost?

    I have the files and db dump from site that works fine in Internet (let's say www.site.com). I imported it to xampp, changed config and paths and .htaccess according to mans. I recieve homepage on localhost/site and can access to /manager. But all site's links and css and image url's are leading to www.site.com. If I manually change site url's in header.Chunks it looses css and images - the url's are leading ti non-existing directory.

    I spent half a day to solve it, didn't find the solution on the Internet.
      • 13226
      • 953 Posts
      Does your site use a base href tag in the HTML source e.g.
      <head>
      <base href="mydomain.com">
      </head>
      

      If yes, take a look at the domain name used in it, it may well still be the domain name of the live website.

      If you have installed the site on localhost in a folder you may need to modify the .htaccess file as such e.g.

      From:
      RewriteEngine On
      RewriteBase /
      

      To:
      RewriteEngine On
      RewriteBase /yourfoldername
      
      [ed. note: iusemodx last edited this post 12 years, 10 months ago.]
        • 22840
        • 1,572 Posts
        There may also be a rule redirecting the none www to www.mydomain.com, if there is comment it out
          • 45638
          • 3 Posts
          Thank you for answers.
          I've tried all above.
          I used default .htaccess and added
          RewriteEngine On
          RewriteBase /yourfoldername

          still no result.

          Yes, site's header contains
          <head>
          <base href="mydomain.com">
          </head>

          I'm new to MODx and didn't find in admin area how to change or remove it. Should I correct the code?
            • 27708 MODX Staff
            • 2,502 Posts
            Typically the best thing to do is have the following for portability as well as for function in different contexts:

            <head>
                <base href="[[++site_url]]">
            </head>
            


            This is normally changed in your template or the chunk for the template top.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
              • 45638
              • 3 Posts
              Ok. Problem solved. I moved site one level higher on localhost with this correction:
              <head>
                  <base href="[[++site_url]]">
              </head>


              Thank you!