【问题标题】:Nginx Rewrite Not workingNginx 重写不工作
【发布时间】:2015-11-24 09:55:21
【问题描述】:

我已将我的网站移至 nginx,但可以正确获取 .htaccess 规则

下面是我的代码

server {
listen 80;
server_name mysite.com;
root /usr/share/nginx/mysite;
index index.php index.html index.htm;

location / {
rewrite ^/(.*)$ /members.php?id=$1 last;
try_files $uri $uri/ =404;

}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

我想显示用户网址

mysite.com/jonny

而不是

mysite.com/memner.php?id=jonny

当我使用时

rewrite ^/(.*)$ /members.php?id=$1 last;

网站无法加载,请帮忙。

【问题讨论】:

  • 如果 (!-e $request_filename) { rewrite /(.*) /members.php?id=$1 last ; }

标签: .htaccess nginx rewrite


【解决方案1】:

解决了这个问题

if (!-e $request_filename) {
rewrite /(.*) /members.php?id=$1 last ;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多