我一直试图让nginx在没有.php或.html扩展的情况下工作,我需要一些帮助.在此先感谢您的时间!我尝试了在How to remove both .php and .html extensions from url using NGINX?找到的解决方案,但它没有效果这是我目前...
我一直试图让nginx在没有.php或.html扩展的情况下工作,我需要一些帮助.在此先感谢您的时间!
我尝试了在How to remove both .php and .html extensions from url using NGINX?找到的解决方案,但它没有效果
这是我目前的nginx配置.它是几个教程的组合,但它的工作原理.
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# ht
tp://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
root /usr/share/nginx/www;
index index.php index.html;
server_name localhost;
location / {
try_files $uri $uri.php $uri.html $uri/ =404;
}
error_page 404 /404.html;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php${
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
# ssl_prefer_server_ciphers on;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
解决方法:
您应该在您认为它形成循环的确切位置添加以下两行.
沃梦达教程
本文标题为:nginx删除.php和.html文件扩展
基础教程推荐
猜你喜欢
- js中.sort()函数的常见用法与高级操作 2023-07-09
- JavaScript实现网页带动画返回顶部的方法详解 2022-10-22
- Ajax实现简单下拉选项效果【推荐】 2022-12-28
- 用CSS来实现一些动画在vue中使用之流星滑过(3) 2023-10-08
- html+css实现分层金字塔的实例 2022-09-20
- 前端ajax的各种与后端交互的姿势 2023-02-01
- 全面解析Ajax和jsonp使用总结 2023-02-14
- 详解Ajax跨域(jsonp) 调用JAVA后台 2023-02-01
- 关于 javascript:如何在页面加载时调用 vue.js 函数 2022-09-16
- 浅谈async、defer以普通script加载的区别 2023-07-09