我只是将我的服务器从apache2切换到nginx,现在我的.htaccess重写有一些问题。
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
我已经收集到,为了使这个工作在Nginx上,我将需要编辑Nginx服务器块。 任何人都可以告诉我如何? 非常感谢你提前。
你可以使用try_files来做类似的事情:
location (.*) { try_files $uri $uri/ /index.php; }
否则你可以使用.htaccess转换http://winginx.com/en/htaccess ,但是因为它是一个自动化的过程,所以不会被优化:
location / { rewrite ^/(.*)/$ /$1 redirect; if (!-e $request_filename){ rewrite ^(.*)$ /index.php break; } }