繁体   English   中英

在Nginx Web服务器中重写规则

[英]Rewrite rule in nginx webserver

我仍然在我的网络服务器中挣扎着make rewrite规则。 当我尝试登录(www.example.com/admin/)到后端时,我只有白页。 但是,如果我尝试添加索引(www.example.com/admin/index)或index.php(www.example.com/admin/index.php),则后端工作正常。 那么,如何编辑功能www.example.com/admin/的代码?

非常感谢您的帮助!

有我的代码:

 server_names_hash_bucket_size  64;

server {
    listen 80;
    server_name example.com;
    return 301 $scheme://www.example.com$request_uri;
}

server {
        listen 80;
        root /usr/share/nginx/www;
        index index.php;
        server_name www.example.com;


    location /admin/ {
        rewrite ^ /admin/index.php;
    } 

   location / {
        rewrite ^([^\.]*)$ /$1.php;
    }

    location = / {
        rewrite ^ /index.php;
    }


    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
      }
}

尝试添加以下内容:

location /admin/ {
    rewrite ^ /admin/index.php;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM