Adding rewrite for www to non-www

The easiest way to add an Nginx rewrite to redirect your traffic from www to non-www is to add the following Nginx code snippet to your domain's ___general/example.com.conf file. set $redirect "0"; if ($host ~* "^www\.example\.com$") { set $redirect "go"; } if ($request_method = PURGE) { set $redirect "0"; } if ($redirect = "go") { … Continue reading

Multistore Magento Configuration

Table of ContentsSharing the document root Identical document root Different document root Setting the run codes Example: Set environment variables for a domain Example: Set environment variables for a sub-domain Example: Set environment variables for a sub-directory Example: Set environment variables for a sub-directory with (optional) languageThere are two elements to making a multi-store environment, … Continue reading

Nginx Configuration Files

Table of ContentsScope Configuration files Applying changesOn MageStack, Nginx has 4 separate configuration files per vhost defined under 2 different directories/scopes, ___general and ___rewrites. Scope Each configuration file serves its own purpose - knowing which to use first is answered by the scope you need to edit. On MageStack, Nginx has two scopes, server and … Continue reading

Using WordPress Multi User (WPMU)

In order to use WordPress with its multi-blog functionality, you need to apply a few rewrite rules to support it. Normally, WordPress would use .htaccess format rules, so these need translating into Nginx format. Here is an example if your main WordPress installation is located in /wp # add a trailing slash to /wp-admin rewrite … Continue reading

Using PHP GeoIP

Table of ContentsEnabling GeoIP Using native GeoIP Included databasesEnabling GeoIP By default, the PHP GeoIP extension is disabled on MageStack (to prevent conflicts if you are using class-based GeoIP libraries). We can enable this on a server-by-server basis, so contact the support team to enable GeoIP. Using native GeoIP MageStack offers native GeoIP functionality so … Continue reading

Adding rewrite for non-www to www

The easiest way to add an Nginx rewrite to redirect your traffic from non-www to www is to add the following Nginx code snippet to your domain's ___general/example.com.conf file. set $redirect "0"; if ($host ~* "^(.+)\.example\.com$") { set $cursubdomain $1; } if ($host != www.example.com) { set $redirect "go"; } if ($cursubdomain = "") { … Continue reading

Changing and testing Nginx configuration

Table of ContentsConfiguration testing Graceful restartingYou can make adjustment to the Nginx rules and rewrites on MageStack by editing two key files /microcloud/domains/example/domains/example.com/___general /microcloud/domains/example/domains/example.com/___rewrites To make the changes effective, you need to restart Nginx, you can do this either Using Monit - by selecting the respective web node, selecting nginx, then pressing "Restart" Using SSH … Continue reading

Running WordPress in subdirectory

As MageStack uses Nginx as the web server, you need to add the following rewrite rules to your respective domain's general rules. Eg. For example.com /microcloud/domains/example/domains/example.com/___general/example.com.conf With the following file contents location /wordpress {try_files $uri $uri/ @wordpress;} location @wordpress { rewrite . /wordpress/index.php last; } Adjust wordpress to suit the name and location of your … Continue reading

Creating subdomains

Creating a new sub-domain is as easy as creating a new directory. Eg. To create http://mynewsubdomain.example.com Log into your acc server with the www-data credentials, then cd /microcloud/domains/example/domains/example.com mkdir mynewsubdomain

Maintenance mode

Table of ContentsToggle maintenance mode by condition Toggle maintenance mode by IP Toggle maintenance mode by URI Toggle maintenance mode by User Agent Toggle maintenance mode by Query ParameterEnabling maintenance mode for a domain is very straightforward. You just need to create a file called .maintenance.on within the root directory for the domain/subdomain/ Eg. /microcloud/domains/example.com/.maintenance.on … Continue reading