登录后端后如何重写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;
}
}
最佳答案
location /administration {
rewrite ^([^\.]*)(\.php)?$ /$1;
}
将该 block 添加到您的配置中将从对/administration 的请求中删除 .php
关于我的管理中的 Nginx URL 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21405004/