Base url issues and subdirectories I have a drupal site at http://example.com and a development version of the same site at http://another.example.com/subdir. When I'm working on the development version, content that references /sites/default/files/ - such as images - doesn't work because it needs to include the '/subdir' part of the path. Setting $base_url doesn't work because that uses the BASE element's href attribute which doesn't affect urls beginning / if the href includes a subdirectory.

What's the best way of including the subdir in the image references? Do I need to resort to a server rewrite?
There are two things you can do here in order to try and make you site more portable.

In your templates:


Always use l() for all links (even JavaScript links)
If you need to reference an image in the theme use: 

&lt;img src="&lt;?php echo $base_path . drupal_get_path('theme', 'themename'); ?&gt;/logo.png" /&gt;



In your content:


You do not really have a way in order to preserve uploaded content URL's unless using some form of file manager which do not create absolute links, but much rather links that get sent to drupal that redirect to the file
If the above is not going to work for you then a modification of the rewrite rules for the drupal site sitting under the subdir is required to basically rewrite all URLs requested that start with sites/default/files/(.*) rewritten to subdir/sites/default/files/$1


And the apache mod_rewrite rule may look like the following.

# Redirect all files requests to a subdir
RewriteRule ^/?sites/default/files/(.*) /subdir/sites/default/files/$1 [R=301,L]