nginx伪静态配置实例
来源:互联网 发布:杰奇网络注册 编辑:程序博客网 时间:2024/06/05 00:25
server
{
listen 80;
server_name bbs.jb51.net;
index index.html index.htm index.php;
root /home/www/bbs;
error_page 404 /404.htm; #配置404错误页面
location ~ .*.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
#下面就是伪静态了
location /{
rewrite ^(.*)/equip(\d+).html$ $1/index.php?m=content&c=index&a=lists&catid=$2 last;
}
access_log access_log off;
}
在ubuntu上部署成功的简单伪静态实例:
####################################################################
server{
listen 80;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
error_page 404 /404.html;
location / {
#try_files $uri $uri/ /index.html;
index index.html;
}
#设置/article/id 读取文章详情的伪静态
location ~* ^/article/(\d+)$ {
set $id $1;
rewrite ^/article/(\d+)$ /article_detail.php?id=$1 last;
#try_files $uri /article_detail.php?id=$id;
}
#设置/news/m/id.html的伪静态
location ~* ^/news/m/(\d+).html {
set $id $1;
try_files $uri /news.php?id=$id;
}
#设置下载打伪静态
location ~* ^/download/m/(.*).html {
set $chanel $1;
try_files $uri /$chanel.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
#php404时触发error_page
fastcgi_intercept_errors on;
}
}
######################################################################
1、当访问 首页时 如 127.0.0.1 会直接找index或index.html页面;
2、当访问 127.0.0.1/article/23 会直接访问 /article_detail.php?id=23;
3、当访问 127.0.0.1/news/m/23.html 会直接访问/news.php?id=23;
4、当访问127.0.0.1/download/m/xiaomi.html 会直接访问/xiaomi.html;
5、当找不到页面时会触发error_page规则,页面直接跳转到/404.html
0 0
- nginx伪静态配置实例
- nginx 配置伪静态
- Nginx伪静态配置
- nginx上支持.htaccess伪静态的配置实例
- nginx伪静态正则转apache伪静态正则 实例
- nginx伪静态rewrite规则写法实例
- Nginx安装配置及伪静态配置
- 在Nginx中配置伪静态
- Thinkphp 伪静态Nginx配置方式
- PHP nginx 去掉伪静态的配置
- ThinkPHP3.2.3+Nginx的伪静态配置
- CodeIgniter3.0+Nginx的伪静态配置
- nginx下wordpress路径、伪静态配置
- nginx配置防盗链及伪静态
- Nginx 下配置支持thinkphp 伪静态
- apache配置伪静态实例 重写技术
- [Nginx] Wordpress在Nginx环境下配置伪静态
- nginx伪静态大全
- java(16)--利用session存储购买商品
- NIO教程 详细版
- 实时采集数据的动态曲线控件
- cocos-html5 button: setEnabled setBright
- iOS 通讯录(OC 语言)
- nginx伪静态配置实例
- 实现Swipe View
- ubuntu初探4---ubuntu安装jdk8&eclipse
- OC 闭源库
- Android项目使用support v7时遇到的各种问题
- onenote发送至博客实践
- AsciiDoc 相关资源
- Android&java的成长之路之四(自定义字母索引)
- LeetCode 64. Minimum Path Sum 解题报告