我在我的旧apache配置(htaccess)中有这个mod_rewrite,我正在尝试将配置设置为nginx,但我无法真正理解它在nginx中是如何工作的,我是所有这一切的新手nginx的东西,任何人都可以帮我翻译一下......非常感谢你提前。
当前的htacces文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(/static/)
RewriteRule . /app.php [L]
</IfModule>
虚拟配置文件test.url:
server {
server_name test.url;
access_log /var/www/test.url/logs/access.log;
error_log /var/www/test.url/logs/error.log;
root /var/www/test.url/public_html/blank;
location / {
app.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/test.url/public_html/$
}
}
答案 0 :(得分:1)
而不是:
location / {
app.php;
}
尝试:
location /static/ {
# do nothing, we don't want to rewrite /static/
}
location / {
try_files $uri $uri/ /app.php
}