How to share filesystem across multisite/subdomains

oxford-dev's picture

My situation is:

I have a website example.com, i want to mirror this site completely except for the theme so that in apache i can direct mobile devices to m.example.com where they can use exactly the same site but with a mobile optimised theme.

I know there are numerous mobile modules out there but they suffer from caching limitations, ie, when a page is accessed from a computer, that same cached page is sent to any subsequent requests, including mobiles.

I know there are also domain/subdomain modules out there also but they are overweight for what i need.

I currently have my main site and a subdomain '/sites/m.example.com' which has the theme folder and settings.php which points to the main database.

I can access and use both sites, the problem is that all links on the original main site are relative so when i access the site via m.example.com, it will try and display files/content from http://m.example.com/sites/default/files/... instead of http://example.com/sites/default/files/... where the file actually resides.

is there a way to rewrite all file access links from m.example.com to example.com?

I would like to achieve this without adding yet more bulky modules if anyone has any ideas? I'm trying to make this as lightweight as possible.

I suppose this would also have to cover file uploads too.

Many thanks!

Comments

Isn't this just a matter of

stevetheboater's picture

Isn't this just a matter of using multiple themes? I do this on the Historic Narrow Boat Owners Club website:

Main site theme www.hnboc.org.uk
Accessible theme: accessible.hnboc.org.uk
Mobile theme: mobile.hnboc.org.uk

The theme selection is done with a bit of code I found on here somewhere (sorry I forget where, but I'm not claiming the credit!) that sits in settings.php:

$parts = explode('.', $_SERVER['SERVER_NAME']);

if(in_array('mobile',$parts)) {
$GLOBALS['custom_theme'] = 'mobile';
}

else {

if(in_array('accessible',$parts)) {
$GLOBALS['custom_theme'] = 'high_contrast';
}

else {
// use usual theme
}

}

The Pathologic module may

Garrett Albright's picture

The Pathologic module may achieve what you're looking for.

The other way to do it

the_g_bomb's picture

Would you not be able to move default file location to /files or somewhere similar instead of sites/example.com/files where both sites share the location and get the files referenced without the fully qualified link?

Have a look here, there are some references to files issues with multi-site setups
http://drupal.org/node/53705

--
G