【发布时间】:2016-12-15 18:49:49
【问题描述】:
我在 Apache2 中使用 .htaccess,效果很好。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9_]+)$ profile.php?username=$1
现在我使用 nginx 重写,在可用的站点中,我进行了这个配置
server {
listen 80;
server_name domain.com;
root /home/domain;
index index.html index.htm index.php;
location / {
rewrite "^([A-Za-z0-9_]+)$" profile.php?username=$1 last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
但它不起作用,它显示 404 Not Found,你能帮我解决这个错误吗?谢谢。
【问题讨论】: