什么是相当于这个mod_rewrite规则的nginx?

我的WordPress的是告诉我更新我的htaccess文件:

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 

我使用nginx,我有这个,但它不工作:

  location / { root /home/mywebsite/public; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ~(.+)$ /index.php?q=$1 last; } } 

尝试改变它到这个;

  location / { root /home/mywebsite/public; index index.php index.html index.htm; try_files $uri $uri/ /index.php; } 

http://wiki.nginx.org/HttpCoreModule#try_files

它的作品完美。

并启用PHP

将PHP脚本传递给在127.0.0.1:9000上监听的FastCGI服务器

  # 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; }