I just pulled a copy from a live site and installed locally using XAMPP. The directory is:
127.0.0.1/website-files/websitename
The homepage pulls up just fine, but no images load. The links do not work either. Image and link URLs have not updated to reflect the new directory. They still show as:
/categoryname/pagename
Instead of
/website-files/websitename/categoryname/pagename
The site is wordpress, and the general settings are updated:
WordPress Address http://127.0.0.1/website-files/websitename
Site Address http://127.0.0.1/website-files/websitename
I added this to functions.php, which I assumed would do all the changes I needed:
update_option('siteurl','http://127.0.0.1/website-files/websitename');
update_option('home','http://127.0.0.1/website-files/websitename');
.htaccess
looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /website-files/websitename/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /website-files/websitename/index.php [L]
</IfModule>
I run into an issue every time I move a website to a new dev server, but this one is a first. What am I missing here?
Avoid using a leading
/
for any links for your website, so instead of:Do this:
And finally, you might want to experiment with adding a “base href” tag to the top of your HTML, which would have a different value depending on what server you’re running on. A quick google for base href will teach you how this works.
You might have to restructure how you build webpages to make this happen. That’s simply how things are if you want to be able to run a single website on more than one server.
If you’re using WordPress or another similar open source framework, you might be screwed. Some of them are simply incapable of operating on more than one server.
Try to confirm that
home
andsiteurl
have been updated in your local database’swp_options
table.Alternately you can can try setting
WP_HOME
andWP_SITEURL
to point to your local files inwp-config.php
. This overrides the settings in the options table.