Skip to content

Instantly share code, notes, and snippets.

@jacine
Created December 1, 2011 23:10
Show Gist options
  • Save jacine/1420589 to your computer and use it in GitHub Desktop.
Save jacine/1420589 to your computer and use it in GitHub Desktop.
My favorite Drupal trick for local theme development
# Find this line and insert the code below it (adapted to use your sitename/server).
# RewriteBase /
# Use files on the dev server instead of syncing them locally.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^sites/sitename/(files/.*)$ http://dev.whatever.com/sites/sitename/$1 [L,QSA]
@jacine
Copy link
Author

jacine commented Dec 1, 2011

This code will allow you to use files located on your dev (or whatever) server while doing local development.

This is awesome because the files directory never uses version control, and most of the time you don't want to rsync the files directory, because it can take up a lot of space on your file system.

Just be careful to never commit/push this code. I tend to use git stash to hold on to it between commits.

I believe this awesome tip originated from @robbiethegeek. ;)

@robbiethegeek
Copy link

Thanks for the nod I definitely have used that since Sony.

@Schnitzel
Copy link

Awesome, thx jacine :)

Only one thing, to get it with Git working without commiting this change:
git update-index --assume-unchanged .htaccess
is your friend, more infos:

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

@msonnabaum
Copy link

Alternatively, you could:

drush dl stage_file_proxy && drush -y en stage_file_proxy

Then put this in your settings.php:

<?php
$conf['stage_file_proxy_origin'] = 'http://dev.whatever.com';

@ezra-g
Copy link

ezra-g commented Dec 1, 2011

The advantage of the stage file proxy module is that it "...transfers each requested file just in time when it is requested" which is generally faster for local development than hotlinking to the production site, and also gives you the benefit of having the files to work with locally eg for imagecache manipulations when you request the original file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment