Subdirectory domain rewrite rule

lurkingbeast's picture

Hi, I'm banging my head with something which should be relatively simple to do.

My scenario is the following:
- 3 sites sharing the same codebase on /var/www/mysite
- each site has it's own database
- The root URLs need to be mysite.com, mysite2.com and mysite2.com/fr
- All three share the same file system on /var/www/mysite/default/files/
- perusio nginx configuration

/var/www/mysite/sites/sites.php:
$sites['mysite.com'] = 'default';
$sites['mysite2.com'] = 'mysite2.com';
$sites['mysite2.com.fr'] = 'mysite2.com.fr';

mysite.com:
- /var/www/mysite/sites/default/settings.php
- /etc/nginx/sites-enabled/mysite.com

mysite2.com:
- /var/www/mysite/sites/mysite2.com/settings.php
** - /etc/nginx/sites-enabled/mysite2.com

mysite2.com/fr:
- /var/www/mysite/sites/mysite2.com.fr/settings.php
** - /etc/nginx/sites-enabled/mysite2.com

(** I just realized that I can just add mysite2.com in the server names mysite.com nginx config)

Now, multisite works fine with mysite.com and mysite2.com, but obviously not with the subdirectory domain /fr, page could not be found.

Could someone give me a hint please, do I need to add a new location = /fr ... or how to change the rewrite to index.php in nginx configuration? I can change the 'mysite2.com' to 'mysite2.com/en' if the rewrite is easier that way.

The reason for this multisite setup is to create quick'n'dirty language options for a site, without the hassle of Domain Access, Entity Translations etc. I already started on those but now the client just wants to paste in the translated content onto each site separately.

Any advice appreciated, thanks

Comments

Hmm

perusio's picture

Your non clean full URI should be http://mysite2.com/fr?q=node/123 for example, I suspect.

Add at the http level:

map $uri $no_lang_uri {
   ^/fr/(?<no_lang_prefix>.*) $no_lang_prefix;
}

Now you need a try_files like this in your drupal.conf:

try_files $uri /fr/index.php?q=$no_lang_uri;

Try it out and report back. Thanks.

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week