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

