.htaccess – URL Rewrite在Nginx中不起作用

URL重写在Nginx中不起作用,操作系统是Ubuntu 12.4 Lts

当打开http://mvc.loc它正在工作
但是当我试图打开http://mvc.loc/login不工作时

404未找到

nginx的/ 1.1.19

.htaccess

<IfModule !mod_rewrite.c>
    ErrorDocument 500 "mod_rewrite must be enabled"
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$/index.php?u=$1

mvc.loc的虚拟主机

server {
    listen 80;
    server_name mvc.loc;
    access_log /var/log/nginx/mvc.loc.access.log;
    error_log /var/log/nginx/mvc.loc.error.log;
    root /usr/share/nginx/www/mvc;

    index       index.php;


    # use fastcgi for all php files
    # Are you sure you have this set up?
    location ~ \.php${
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # deny access to apache .htaccess files
    location ~ /\.ht {
     deny all;
    }

}
最佳答案
location / {    
   rewrite ^(.*)$/index.php?u=$1 last;
}

转载注明原文:.htaccess – URL Rewrite在Nginx中不起作用 - 代码日志