Nginx 伪静态

location / {
    if (!-e $request_filename) {
        rewrite ^/(.*\.(js|ico|gif|jpg|png|css|bmp|html|xls)$) /$1 last;
        rewrite ^/(\?\?.*\.(js|css).*$) /$1 last;
        #rewrite url "www.a.com/1.php" TO "www.a.com/1"
        rewrite ^/(.*) /$1.php last;
        #rewrite "^/?code=(.*)$" /index.php?user/weibocallback?code=$1 break;
    }
}
时间: 2024-08-14 10:55:14

Nginx 伪静态的相关文章

Nginx伪静态配置和常用Rewrite伪静态规则

伪静态是一种可以把文件后缀改成任何可能的一种方法,如果我想把php文件伪静态成html文件,这种相当简单的,下面来介绍nginx 伪静态配置方法有需要了解的朋友可参考. nginx里使用伪静态是直接在nginx.conf 中写规则的,并不需要像apache要开启写模块(mod_rewrite)才能进行伪静态. nginx只需要打开nginx.conf配置文件,在server里面写需要的规则即可. 代码如下: server { listen       80; server_name  haha.

nginx伪静态配置教程总结

在nginx中配置伪静态,也就是常说的url重写功能,只需在nginx.conf配置文件中写入重写规则即可. 当然,这个规则是需要熟悉正则表达式,只掌握nginx自身的正则匹配模式即可,对正则不了解的朋友,建议补一下这方面的知识. 下面,收集了几篇关于nginx rewrite重写的教程文章,感兴趣的朋友可以看看. nginx伪静态.url rewrite重写教程: nginx配置301重定向及rewrite重写规则说明 nginx rewrite重写规则语句配置示例 nginx中url重写规则

Nginx伪静态规则

nginx伪静态规则 要将http://lovo.com/index.php?t=3用伪静态规则改写成http://lovo.com/t3.html,即可在nginx的conf/nginx.conf里面添加即可. 在location / {}里添加,如: location / {            root   /var/www/html;            index  index.php index.html index.htm;            rewrite ^(.*)/t

Drupal Nginx伪静态设置方法

location ~ ^.*/files\/styles\/.*$ { access_log off; expires 45d; error_page 404 @drupal; } location @drupal { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; } } # Drupal Rewrite location / { root /path/to/drupal; index index.php i

php配置伪静态如何将.htaccess文件转换 nginx伪静态文件

php通常设置伪静态三种情况,.htaccess文件,nginx伪静态文件,Web.Config文件得形式,如何将三种伪静态应用到项目中呢, 1,.htaccess文件 实例 <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ inde

nginx 伪静态 rewrite

前一段时间领导让我用nginx做个伪静态,实现效果如下: 原URL http://www.domain.com/abc/def.jsp?x=1&y=2&z=3 转换为http://www.domain.com/abc/def-1-2-3.html,当我访问原URL时,浏览器的地址栏里显示的是转换后的URl,但内容还是原来动态页面的内容. 开始我是这么写的 rewrite ^/abc/def-(.*)\-(.*)\-(.*)\.html$ /abc/def.jsp?x=$1&y=$2

nginx伪静态

前言 当公司有一个首页,一个测试页的时候会用到nginx的伪静态 当index.php与index1.php,的时候可以用到. 峰会路转言归正传开整 location / { index index.html index.htm index1.php index.php; } #有"定位"的意思, 根据Uri来进行不同的定位. #在虚拟主机的配置中,是必不可少的,location可以把网站的不同部分,定位到不同的处理方式上. location ~ \.php$ { 总结:多学pytho

thinkphp配置nginx伪静态并解决PATHINFO问题和fix_pathinfo漏洞

nginx.conf的server配置,当文件不存在时,就采用伪静态 server{ listen 801; index index.html index.htm index.php; root D:/data/code/jsjh-admin/wwwroot; location /{ if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } } include dotphp.conf; } dotphp.conf配置php的

CI框架 CodeIgniter 伪静态 htaccess设置和Nginx伪静态方法

众所周知,LAMP代表Linux下Apache.MySQL.PHP这种网站服务器架构:而LNMP指的是Linux下Nginx.MySQL.PHP这种网站服务器架构.LNMP一键安装包可以从网上下载使用. Nginx(发音同 engine x)由 Igor Sysoev 用C语言为俄罗斯访问量第二的搜索引擎 Rambler.ru 站点开发,是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3/SMTP)代理服务器,其将源代码以类BSD许可证的形式发布,并在一个BSD-like

nginx 伪静态的设置

以下操作实现当用户访问 www.tetuhao.com/link.html 时,显示的是www.tetuhao.com/shop/index.php?act=link  的内容.同时网址显示的仍是www.tetuhao.com/link.html 一:vim /usr/local/nginx/conf/nginx.conf     在server块中加入以下内容              location / {        rewrite ^(.*)/link\.html$ $1/shop/