By aardvark7 on
Hi,
Drupal on my production site is in the root directory but for my development site is in localhost/drupal. I've just restored the production database in the test environment but naturally some links/images no longer work as they are looking at the root (localhost) rather than the sub-directory (localhost/drupal).
Is there an easy way to fix this short of re-editing my links/images each time (which I would need to repeat when moving to production). I've tried using settings.php and .htaccess but without success.
Apologies if this has already been discussed in the forum - I've not been able to locate anything on this ...
Any guidance will be very much appreciated.
andrew
Comments
u should use dynamic path for
u should use dynamic path for images. then whereever u will upload ur cms, it will work fine.
dynamic path is '
print base_path() . path_to_theme()/images/filename'The
The http://drupal.org/project/pathologic module might help fix the links on the fly.
But the most reliable way to avoid having to edit the links in the content is to make your development sites use the same base path as the development sites. You could do this by setting up local domain or subdomain URLs instead of subdirectory URLs (http://site1 or http://sub.localhost instead of http://localhost/sub) so that you don't have paths.
if possible, i'd create your
(oops, posted at the same time as cog.rusty)
if possible, i'd create your local dev site as a peer of your production site. e.g.:
http://example.com -- production site
http://dev.example.com -- dev site
you can then use PHP functions/variables in your theme (as aakanksha mentions) and root relative links in your content (i.e. starting with '/') for simple database portability. e.g.:
there are a lot of good resources out there to help you set up that local dev site. here are some notes i wrote up a while back.
Thanks
Belated thanks to all and sundry for your help. This fixed up for me.
Chrs,
A