I just migrate from Apache to Nginx and trying to set up rewrite rules. I have a virtual host and this is the structure of virtual host
/var/www/name-of-virtual-host/
├── wp1
│ ├── wp-admin
│ ├── wp-content
│ └── wp-includes
└── wp2
├── wp-admin
├── wp-content
└── wp-includes
As you see I have 2 different WordPress installations in different folders. So I'm trying to create a rewrite rule to work with these 2 WPs.
This is my location definition:
location / {
try_files @missing $uri;
}
location @missing {
rewrite ^/([a-z-])(/.*)$ /$1/index.php last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
If URI is /wp1/permalink-of-post/ it should use /wp1/index.php and if /wp2/permalink-of-post/ it should use /wp2/index.php .
But I'm getting rewrite or internal redirection cycle while internally redirecting to error.
How can I write my rewrite rules to use with multiple WP installations ?
UPDATE 1
An example WordPress .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp1/index.php [L]
</IfModule>
# END WordPress