Convert lighttpd rewrite rule to nginx

justin nginx-forum at
Tue Jul 24 01:23:06 UTC 2012

I have the following simple lighttpd rewrite rule:

    $HTTP["host"] =~ "^(app\.mydomain\.com)$" {
        url.rewrite-once = (
                "^[^.]*$" => "controller.php/$1"

I am trying to port this rule to nginx and have the following:

    server {
      listen 80;


      if ($host = '') {
        rewrite ^[^.]*$ controller.php/$1 last;

      root /srv/www/domains/;

      index index.php;

      access_log /var/log/nginx/domains/;
      error_log /var/log/nginx/domains/;

      include /etc/nginx/excludes.conf;
      include /etc/nginx/php.conf;
     include /etc/nginx/expires.conf;

The problem is that the rewrite rule for nginx is not working correctly?
Any idea what I am doing wrong?

Thanks much.

Posted at Nginx Forum:,228909,228909#msg-228909

More information about the nginx mailing list