WordPress與Drupal的Nginx配置rewrite重寫規(guī)則示例
WordPress
wordpress依然是目前是世界上最流行的博客系統(tǒng),越來越多由wordpress搭建而成的網(wǎng)站在使用nginx服務(wù)器軟件,這里就來分享一下WordPress的nginx重寫規(guī)則:
server {
listen 80;
server_name www.dbjr.com.cn jb51.net;
access_log /data/logs/nginx/www.dbjr.com.cn.access.log main;
index index.html index.php;
root /data/site/www.dbjr.com.cn;
location / {
try_files $uri $uri/ /index.php?$args;
add_header Pragma "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重寫規(guī)則
Drupal是使用PHP語言編寫的開源內(nèi)容管理框架,就是俗稱的CMS,很多人在用Drupal搭建自己的博客,這里也來分享一下Drupal的nginx重寫規(guī)則:
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?q=$1;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "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
相關(guān)文章
nginx重定向解決(rewrite or internal redirection&nb
本文主要介紹了nginx重定向解決,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-11-11
Nginx下WordPress鏈接(url偽靜態(tài))301永久重定向?qū)崿F(xiàn)方法
在幾個blog程序中折騰的結(jié)果,導(dǎo)致url連續(xù)二次變化。這是第三次了。 nginx 通過rewrite 使用 permanent; 參數(shù) 成301永久url重定向2012-09-09
Nginx配置srcache_nginx模塊搭配Redis建立緩存系統(tǒng)
這篇文章主要介紹了Nginx配置srcache_nginx模塊搭配Redis建立緩存系統(tǒng)的方法,文中關(guān)于Nginx模塊和Redis數(shù)據(jù)庫的安裝就不再說明了,這里只關(guān)注配置搭建階段,需要的朋友可以參考下2016-01-01
Mac中使用Nginx實現(xiàn)80端口轉(zhuǎn)發(fā)8080端口
端口轉(zhuǎn)發(fā)(Port forwarding),有時被叫做隧道,是安全殼(SSH) 為網(wǎng)絡(luò)安全通信使用的一種方法。端口轉(zhuǎn)發(fā)是轉(zhuǎn)發(fā)一個網(wǎng)絡(luò)端口從一個網(wǎng)絡(luò)節(jié)點到另一個網(wǎng)絡(luò)節(jié)點的行為,其使一個外部用戶從外部經(jīng)過一個被激活的NAT路由器到達(dá)一個在私有內(nèi)部IP地址(局域網(wǎng)內(nèi)部)上的一個端口2017-09-09
詳解nginx.conf 中 root 目錄設(shè)置問題
這篇文章主要介紹了詳解nginx.conf 中 root 目錄設(shè)置問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09

