服务器 
首页 > 服务器 > 浏览文章

WordPress与Drupal的Nginx配置rewrite重写规则示例

(编辑:jimmy 日期: 2024/9/17 浏览:3 次 )

WordPress

wordpress依然是目前是世界上最流行的博客系统,越来越多由wordpress搭建而成的网站在使用nginx服务器软件,这里就来分享一下WordPress的nginx重写规则:
 

  server {
    listen    80;
    server_name www.jb51.net jb51.net;
    access_log /data/logs/nginx/www.jb51.net.access.log main;
 
    index index.html index.php;
    root /data/site/www.jb51.net;
location / {
    try_files $uri $uri/ /index.php"public";
    expires 12h;
}
 
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
 
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    access_log off;
      log_not_found off;
      expires max;
}
 
 
location ~ \.php$ {
    try_files $uri =404;
 
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#    fastcgi_intercept_errors on;
    fastcgi_pass 127.0.0.1:9000;
}
 
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
    expires 24h;
    access_log off;
}
 
location ~ .*\.(js|css)$
{
    expires 24h;
    access_log off;
}

 重启你的nginx即可

Drupal nginx重写规则
Drupal是使用PHP语言编写的开源内容管理框架,就是俗称的CMS,很多人在用Drupal搭建自己的博客,这里也来分享一下Drupal的nginx重写规则:

server {
 ...
location / {
 # This is cool because no php is touched for static content
 try_files $uri @rewrite;
 }
location @rewrite {
 # Some modules enforce no slash (/) at the end of the URL
 # Else this rewrite block wouldn't be needed (GlobalRedirect)
 rewrite ^/(.*)$ /index.php"cgi.fix_pathinfo = 0;" in php.ini
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_intercept_errors on;
 fastcgi_pass unix:/tmp/phpfpm.sock;
 }
...
 }

 
重启nginx

上一篇:Nginx配置的rewrite编写时last与break的区别分析
下一篇:使Nginx服务器支持中文URL的相关配置详解
一句话新闻
一文看懂荣耀MagicBook Pro 16
荣耀猎人回归!七大亮点看懂不只是轻薄本,更是游戏本的MagicBook Pro 16.
人们对于笔记本电脑有一个固有印象:要么轻薄但性能一般,要么性能强劲但笨重臃肿。然而,今年荣耀新推出的MagicBook Pro 16刷新了人们的认知——发布会上,荣耀宣布猎人游戏本正式回归,称其继承了荣耀 HUNTER 基因,并自信地为其打出“轻薄本,更是游戏本”的口号。
众所周知,寻求轻薄本的用户普遍更看重便携性、外观造型、静谧性和打字办公等用机体验,而寻求游戏本的用户则普遍更看重硬件配置、性能释放等硬核指标。把两个看似难以相干的产品融合到一起,我们不禁对它产生了强烈的好奇:作为代表荣耀猎人游戏本的跨界新物种,它究竟做了哪些平衡以兼顾不同人群的各类需求呢?
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap