First I want to thank you for this great module!

My goal to access the software:
Drupal: drupal.example.com
Embedded Gallery: gallery.example.com

Is there a chance to access the embedded gallery (drupal.example.com/gallery) by a separate (sub)domain (gallery.example.com)? For example: I want to direct the domain to drupal folder and then adding a .htaccess rule for this (sub)domain to use drupal.example.com/gallery as path ... would this be possible? (I don't know .htaccess rules well)

Comments

profix898’s picture

The easiest way to achieve what you want is to redirect from your subdomain (gallery.example.com) to the gallery path of your drupal domain (drupal.example.com/gallery). To do so add the following lines to .htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} sub.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/gallery/$1 [L]

Try to google for 'subdomain redirect htaccess' (or similar) and you will find many examples and help on your problem.

Roi Danton’s picture

Thx!

Though I searched the web and read the Apache documentation I didn't found a way where gallery.example.com won't be substituted by drupal.example.com/gallery/ after redirecting. I want that users never see drupal.example.com/gallery/ in the URL, only gallery.examples.com.

profix898’s picture

a way where gallery.example.com won't be substituted by drupal.example.com/gallery/ after redirecting

That is not possible with Apache only AFAIK.

You can however create a VirtualHost for your subdomain and point its document root to the same path as your drupal (sub) domain and redirect to a subdirectory there. What means gallery.example.com/xyz will be redirected to gallery.example.com/gallery/xyz. This way your users would stay on gallery.example.com (but are able to access other drupal pathes as well).

Subdomains are still different domains. As you want the gallery to be shown embedded in Drupal you will also have to use the drupal domain to access the content. Its no problem to access your standalone Gallery2 using the subdomain though. But as long as Gallery2 is embedded in Drupal it IS Drupal you are accessing. The only exception is the use of a proxy to translate the domains transparently, e.g. you can use mod_proxy and the [P] option with your rewrite rules.

I am no htaccess/Apache/... guru and this is the issue queue for the gallery module. I suggest you post to the forums ...

Roi Danton’s picture

It actually works:

  • Set the path of gallery.example.com to Drupal directory
  • Add following lines to Drupal .htaccess:
    # Added for gallery subdomain
    RewriteEngine on
    RewriteCond %{HTTP_HOST} gallery.example.com$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?q=gallery$1 [L]
    
  • If Drupal is accessed by a subdomain (e.g drupal.example.com), too: Edit your Cookie Domain in Drupal's settings.php. Out-comment the lines for Drupals default Cookie Domain and add:
    ini_set('session.cookie_domain', '.example.net');
    

Disadvantage: All Drupal links are also available by gallery.example.com and relative links in Drupal blocks are accessed by gallery.example.com/Drupallink. The same vice versa: From within native Druapl the links in gallery blocks are still drupal.example.com/Gallerylink. So Drupal and gallery are fully available by these two (sub)domains. Currently I don't know how to change the links in the blocks.

Roi Danton’s picture

Status: Active » Fixed

The disadvantages posted one message above can be removed by using mod_rewrite, too.

Anonymous’s picture

Status: Fixed » Closed (fixed)
mbarberis’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

Hi,
please Roi can you post your complete solution (message #5)?

My goal is: have only one Drupal installation (www.mysite.com) and one subdomain (private.mysite.com) that use the private module installed in sites/mysite.com/modules. "Private" is an example module name..
It isn't a multi-site request.

Requests for http://private.mysite.com -> must uses private module.

Requests for http://private.mysite.com/{anything} -> must uses only private module path and aliases.

Requests for http://www.mysite.com/private or http://www.mysite.com/private/{anything} -> must not works (redirect to front or http://private.mysite.com/).

Thanks,
Marco

Roi Danton’s picture

(Though the request isn't specifically for gallery module.)

Two steps:

1) Depending on how you access your private Module rewrite at first the general Drupal link into the subdomain, e.g.
http://private.mysite.com/{anything} -> http://www.mysite.com?q=link_to_your_private_module/{anything}

    RewriteCond %{HTTP_HOST} private\.mysite\.com$ [NC]
    RewriteCond %{THE_REQUEST} /([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/index\.php$
    RewriteRule .   /index.php?q=link_to_your_private_module/%1   [QSA,L]

2) Afterwards modify your links to the "Private" Module with the appropriate subdomain.

Hope I'd understood your request correct (not sure though).