如何在登录后端后重写URL?我需要将以下内容从 www.domain.com/administration/index.php,www.domain.com/administration/nextpage.php 更改为 www.domain.com/administration/index ,www.domain.com/administration/nextpage 这是我的实际配置:
server {
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
server {
listen 80;
root /usr/share/nginx/www;
index index.php;
server_name www.domain.com;
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;
}
}
答案 0 :(得分:1)
当实际URI失败时,这将尝试添加扩展名PHP
location /administration {
try_files $uri $uri/ /$uri.php$is_args$query_string;
}
答案 1 :(得分:1)
location /administration {
rewrite ^([^\.]*)(\.php)?$ /$1;
}
将该块添加到您的配置将从请求/管理
中删除.php