We're moving from apache to NGINX and Hip Hop Virtual Machine (HHVM). I can't seem to get our rewrite rules lined up and working properly in NGINX. Here is the current working apache rule set:
RewriteEngine On RewriteBase /
#send www.domain.com -> domain.com
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^(.*)$ http://domain.com%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule td/api(.*) http://dp.domain.com/api$1 [P,L]
RewriteRule ^.*$ /index.php [NC,L]
</IfModule>
Here is what I have tried currently:
server {
server_name test.domain.com;
listen 80;
root /path/public_html;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path/public_html/index.php;
include fastcgi_params;
}
}