RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

User Tools

Site Tools


Sidebar


Навигация

Линкшэринг

ALARM!

Добавить новую страницу

You are not allowed to add pages
linux:nginx:nginx_rewrite_dokuwiki

Примеры rewrite для Nginx

Dokuwiki

location /wiki {
    index index.php;
    access_log logs/wiki.log;
    error_log logs/wiki-error.log;

    rewrite ^/wiki/_media/(.*) lib/exe/fetch.php?media=$1 last;
    rewrite ^/wiki/_detail/(.*) lib/exe/detail.php?media=$1 last;
    rewrite ^/wiki/_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2 last;

    if (!-e $request_filename) {
        rewrite ^/wiki/(.+)$ /wiki/doku.php?id=$1 last;
    }

    if ($request_uri ~ ^/wiki/(bin|conf|data|inc)) {
        return 403;
    }

    rewrite ^/wiki/index.php$ doku.php;
}

Opencart 3

location /image/data {
	autoindex on;
}    

location /admin {
	index index.php;
}
	
location = /sitemap.xml {
	rewrite ^(.*)$ /index.php?route=feed/google_sitemap break; 
	} 

location = /googlebase.xml {
	rewrite ^(.*)$ /index.php?route=feed/google_base break; 
} 

location / {
	try_files $uri $uri/ @opencart;
}
    
location @opencart {
	rewrite ^/en/([^?]*) /index.php?_route_=$1&lang=en-gb last;
	rewrite ^/en$ /index.php?_route_=$1&lang=en-gb last;
	rewrite ^/cz/([^?]*) /index.php?_route_=$1&lang=cs-cz last;
	rewrite ^/cz$ /index.php?_route_=$1&lang=cs-cz last;
	rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
	
location = /favicon.ico {
	log_not_found off;
	access_log off;
}

location = /robots.txt {
	allow all;
	log_not_found off;
	access_log off;
}

location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
	deny all;
}

location ~ /\. {
	deny all;
	access_log off;
	log_not_found off;
}
    
location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
	expires 7d;
	log_not_found off;
}
    
location ~ \.php$ {
	try_files $uri =404;
	include /etc/nginx/fastcgi_params;
	fastcgi_pass 127.0.0.1:9000;
	fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
	}

Sticky notes

rewrite ^/install/?$ /install.php;
        rewrite ^/doc/([a-z]+)/?$ /doc.php?cat=$1;
        rewrite ^/~([a-z.]+)/doc/([a-z]+)/?$ /doc.php?project=$1&cat=$2;
        rewrite ^/~([a-z.]+)/?$ /index.php?project=$1;
        rewrite ^/~([a-z.]+)/api/([a-z]+)/?$ /index.php?project=$1&mode=$2;
        rewrite ^/all/?$ /list.php;
        rewrite ^/api/([a-z]+)/all/?$ /list.php?mode=$1;
        rewrite ^/~([a-z.]+)/api/([a-z]+)/all/?$ /list.php?project=$1&mode=$2;
        rewrite ^/rss/?$ /list.php?rss=1;
        rewrite ^/~([a-z.]+)/rss/?$ /list.php?project=$1&rss=1;
        rewrite ^/all/([0-9]+)/?$ /list.php?page=$1;
        rewrite ^/api/([a-z]+)/all/([0-9]+)/?$ /list.php?mode=$1&page=$2;
        rewrite ^/~([a-z.]+)/all/([0-9]+)/?$ /list.php?project=$1&page=$2;
        rewrite ^/~([a-z.]+)/api/([a-z]+)/all/([0-9]+)/?$ /list.php?project=$1&mode=$2&page=$3;
        rewrite ^/([0-9]+)/?$ /show.php?id=$1;
        rewrite ^/~([a-z.]+)/([0-9]+)/?$ /show.php?project=$1&id=$2;
        rewrite ^/([0-9]+)/([a-z|A-Z]+)/?$ /show.php?id=$1&mode=$2;
        rewrite ^/~([a-z.]+)/([0-9]+)/([a-z|A-Z]+)/?$ /show.php?project=$1&id=$2&mode=$3;
        rewrite ^/api/([a-z|A-Z]+)/([0-9]+)/?$ /show.php?mode=$1&id=$2;
        rewrite ^/~([a-z.]+)/api/([a-z|A-Z]+)/([0-9]+)/?$ /show.php?project=$1&mode=$2&id=$3;
        rewrite ^/([0-9]+)/([0-9]+)/?$ /show.php?id=$1&hash=$2;
        rewrite ^/~([a-z.]+)/([0-9]+)/([0-9]+)/?$ /show.php?project=$1&id=$2&hash=$3;
        rewrite ^/([0-9]+)/([0-9]+)/([a-z|A-Z]+)/?$ /show.php?id=$1&hash=$2&mode=$3;
        rewrite ^/~([a-z.]+)/([0-9]+)/([0-9]+)/([a-z|A-Z]+)/?$ /show.php?project=$1&id=$2&hash=$3&mode=$4;
        rewrite ^/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/?$ /show.php?mode=$1&id=$2&hash=$3;
        rewrite ^/~([a-z.]+)/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/?$ /show.php?project=$1&mode=$2&id=$3&hash=$4;
        rewrite ^/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/(.*)$ /show.php?mode=$1&id=$2&hash=$3&password=$4;
        rewrite ^/~([a-z.]+)/api/([a-z|A-Z]+)/([0-9]+)/([0-9]+)/(.*)$ /show.php?project=$1&mode=$2&id=$3&hash=$4&password=$5;

Flyspray

location / {
			rewrite ^/.*\?do=admin&area=prefs$ /index.php?do=admin&area=prefs break;
			rewrite ^/([0-9]+)$ /index.php?do=details&task_id=$1 break;
		}

		location /task {
			rewrite ^/task/([0-9]+)$ /index.php?do=details&task_id=$1 break;
			rewrite ^/task/([0-9]+)comment([0-9]+)$ /index.php?do=details&task_id=$1comment$2 break;
			rewrite ^/task/([0-9]+)/depends$ /index.php?do=depends&task_id=$1 break;
			rewrite ^/task/([0-9]+)/depends&prune=([0-9]+)$ /index.php?do=depends&task_id=$1&prune=$2 break;
			rewrite ^/task/([0-9]+)/edit$ /index.php?do=details&task_id=$1&edit=yep break;
		}

		location = /newtask {
			rewrite ^(.*)$ /index.php?do=newtask break;
			rewrite ^(.*)$ /index.php?do=newtask break;
		}

		location /newtask {
			rewrite ^/newtask/proj([0-9]+)$ /index.php?do=newtask&project=$1 break;
		}

		location = /reports {
			rewrite ^(.*)$ /index.php?do=reports break;
		}

		location = /myprofile {
			rewrite ^(.*)$ /index.php?do=myprofile break;
		}

		location /user {
			rewrite ^/user/([0-9]+)$ /index.php?do=user&id=$1 break;
		}

		location = /logout {
			rewrite ^(.*)$ /index.php?do=authenticate&logout=1 break;
		}

		location /admin {
			rewrite ^/admin/([a-zA-Z]+)$ /index.php?do=admin&area=$1 break;
			rewrite ^/admin/editgroup/([0-9]+)$ /index.php?do=admin&area=editgroup&id=$1 break;
		}

		location /pm {
			rewrite ^/pm/proj([0-9]+)/([a-zA-Z]+)$ /index.php?do=pm&project=$1&area=$2 break;
			rewrite ^/pm/editgroup/([0-9]+)$ /index.php?do=pm&area=editgroup&id=$1 break;
		}

		location /edituser {
			rewrite ^/edituser/([0-9]+)$ /index.php?do=admin&area=users&user_id=$1 break;
		}

		location = /register {
			rewrite ^(.*)$ /index.php?do=register break;
		}

		location = /lostpw {
			rewrite ^(.*)$ /index.php?do=lostpw break;
		}

		location = /roadmap {
			rewrite ^(.*)$ /index.php?do=roadmap break;
		}

		location /roadmap {
			rewrite ^/roadmap/proj([0-9]+)$ /index.php?do=roadmap&project=$1 break;
		}

		location = /toplevel {
			rewrite ^(.*)$ /index.php?do=toplevel break;
		}

		location /toplevel {
			rewrite ^/toplevel/proj([0-9]+)$ /index.php?do=toplevel&project=$1 break;
		}

		location = /index {
			rewrite ^(.*)$ /index.php?do=index break;
		}

		location /index {
			rewrite ^/index/proj([0-9]+)$ /index.php?do=index&project=$1 break;
		}

		location /proj {
			rewrite ^/proj([0-9]+)$ /index.php?project=$1 break;
		}

Joomla

http://docs.joomla.org/Nginx

server {
        listen 80;
        server_name YOUR_DOMAIN;
        server_name_in_redirect off;

        access_log /var/log/nginx/localhost.access_log main;
        error_log /var/log/nginx/localhost.error_log info;

        root PATH_ON_SERVER;
        index index.php;
        # Support Clean (aka Search Engine Friendly) URLs
        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        index index.php index.html index.htm default.html default.htm;
        # deny running scripts inside writable directories
        location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                return 403;
                error_page 403 /403_error.html;
        }

        location ~ .*.php$ {
            include /etc/nginx/fastcgi.conf;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        # caching of files 
        location ~* \.(ico|pdf|flv)$ {
                expires 1y;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
                expires 14d;
        }

}

Wordpress

General WordPress rules

# WordPress single blog rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
	try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
	expires 24h;
	log_not_found off;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
	# Zero-day exploit defense.
	# http://forum.nginx.org/read.php?2,88845,page=3
	# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
	# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
	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 php;
}

WordPress Multisite Subdirectory rules

For multisite subdirectory installations, here is the 'global/wordpress.conf' file:

# WordPress multisite subdirectory rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
	try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
	expires 24h;
	log_not_found off;
}

# Pass uploaded files to wp-includes/ms-files.php.
rewrite /files/$ /index.php last;

# For multisite:  Use a caching plugin that creates symlinks to the correct subdirectory structure to get some performance gains.
set $cachetest "$document_root/wp-content/ms-filemap/${host}${uri}";
if ($uri ~ /$) {
	set $cachetest "";
}
if (-f $cachetest) {
	# Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
	rewrite ^ /wp-content/ms-filemap/${host}${uri} break;
}

if ($uri !~ wp-content/plugins) {
	rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-ms-subdir-wp-super-cache.conf;
#include global/wordpress-ms-subdir-w3-total-cache.conf;

# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
	rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
	rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
	rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
	# Zero-day exploit defense.
	# http://forum.nginx.org/read.php?2,88845,page=3
	# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
	# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
	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 php;
}

This configuration may also work for subdomain installations without modification. This configuration may also work for a single blog installation (non-network/multisite).

WP Super Cache Rules

# WP Super Cache rules.
# Designed to be included from a 'wordpress-ms-...' configuration file.

# Enable detection of the .gz extension for statically compressed content.
# Comment out this line if static gzip support is not compiled into nginx.
gzip_static on;

set $supercacheuri "";
set $supercachefile "$document_root/wp-content/cache/supercache/${http_host}${uri}index.html";
if (-e $supercachefile) {
	set $supercacheuri "/wp-content/cache/supercache/${http_host}${uri}index.html";
}

# If this is a POST request, pass the request onto WordPress.
if ($request_method = POST) {
	set $supercacheuri "";
}

# If there is a query string, serve the uncached version.
if ($query_string) {
	set $supercacheuri "";
}

# Logged in users and those who have posted a comment get the non-cached version.
if ($http_cookie ~* comment_author_|wordpress_logged_in|wp-postpass_) {
	set $supercacheuri "";
}

# Mobile browsers get the non-cached version.
# Wastes CPU cycles if there isn't a mobile browser WP theme for the site.
if ($http_x_wap_profile) {
	set $supercacheuri "";
}

if ($http_profile) {
	set $supercacheuri "";
}

if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
	set $supercacheuri "";
}

if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
	set $supercacheuri "";
}

# Stop processing if the supercache file is valid.
if ($supercacheuri) {
	rewrite ^ $supercacheuri break;
}

DLE

server {
    listen       IP_ADDR:80;
    server_name HOST;

    root /path/to/root;

    rewrite ^/page/(.*)$ /index.php?cstart=$1 last;

    location / {
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})(/?)+$" /index.php?year=$1&month=$2&day=$3 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)(/?)+$" /index.php?year=$1&month=$2&day=$3&cstart=$4 last;
        rewrite "^/([0-9]{4})/([0-9]{2})(/?)+$" /index.php?year=$1&month=$2 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/page/([0-9]+)(/?)+$" /index.php?year=$1&month=$2&cstart=$3 last;
        rewrite "^/([0-9]{4})(/?)+$" /index.php?year=$1 last;
        rewrite "^/([0-9]{4})/page/([0-9]+)(/?)+$" /index.php?year=$1&cstart=$2 last;
        rewrite "^/([^.]+)(/?)+$" /index.php?do=cat&category=$1 last;
        rewrite "^/([^.]+)/page/([0-9]+)(/?)+$" /index.php?do=cat&category=$1&cstart=$2 last;
        index  index.php index.html index.htm;
    }

    location /tags/ {
        rewrite ^/tags/([^/]*)(/?)+$ /index.php?do=tags&tag=$1 last;
        rewrite ^/tags/([^/]*)/page/([0-9]+)(/?)+$ /index.php?do=tags&tag=$1&cstart=$2 last;
    }

    location /user/ {
        rewrite ^/user/([^/]*)/rss.xml$ /engine/rss.php?subaction=allnews&user=$1 last;
        rewrite ^/user/([^/]*)(/?)+$ /index.php?subaction=userinfo&user=$1 last;
        rewrite ^/user/([^/]*)/page/([0-9]+)(/?)+$ /index.php?subaction=userinfo&user=$1&cstart=$2 last;
        rewrite ^/user/([^/]*)/news(/?)+$ /index.php?subaction=allnews&user=$1 last;
        rewrite ^/user/([^/]*)/news/page/([0-9]+)(/?)+$ /index.php?subaction=allnews&user=$1&cstart=$2 last;
        rewrite ^/user/([^/]*)/news/rss.xml(/?)+$ /engine/rss.php?subaction=allnews&user=$1 last;
    }

    location /lastnews/ {
        rewrite ^/lastnews/(/?)+$ index.php?do=lastnews last;
        rewrite ^/lastnews/page/([0-9]+)(/?)+$ /index.php?do=lastnews&cstart=$1 last;
    }

    location /catalog/ {
        rewrite ^/catalog/([^/]*)/rss.xml$ /engine/rss.php?catalog=$1 last;
        rewrite ^/catalog/([^/]*)(/?)+$ /index.php?catalog=$1 last;
        rewrite ^/catalog/([^/]*)/page/([0-9]+)(/?)+$ /index.php?catalog=$1&cstart=$2 last;
    }

    location /newposts {
        rewrite ^/newposts(/?)+$ /index.php?subaction=newposts last;
        rewrite ^/newposts/page/([0-9]+)(/?)+$ /index.php?subaction=newposts&cstart=$1 last;
    }

    location /favorites {
        rewrite ^/favorites(/?)+$ /index.php?do=favorites last;
        rewrite ^/favorites/page/([0-9]+)(/?)+$ /index.php?do=favorites&cstart=$1 last;
    }

    location ~ \.(html|xml) {
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$" /engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 last;
        rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4 last;
        rewrite "^/([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$4&news_page=$2&cstart=$3 last;
        rewrite "^/([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$3&news_page=$2 last;
        rewrite "^/([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /engine/print.php?news_page=$2&newsid=$3 last;
        rewrite "^/([^.]+)/([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$2 last;
        rewrite "^/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$3&news_page=$1&cstart=$2 last;
        rewrite "^/page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$2&news_page=$1 last;
        rewrite "^/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$" /engine/print.php?news_page=$1&newsid=$2 last;
        rewrite "^/([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$1 last;
        rewrite "^/static/(.*).html(/?)+$" /index.php?do=static&page=$1 last;
        rewrite ^/rules.html$ /index.php?do=rules last;
        rewrite ^/statistics.html$ /index.php?do=stats last;
        rewrite ^/addnews.html$ /index.php?do=addnews last;
        rewrite ^/([^.]+)/rss.xml$ /engine/rss.php?do=cat&category=$1 last;
        rewrite ^/page,([0-9]+),([^/]+).html$ /index.php?do=static&page=$2&news_page=$1 last;
        rewrite ^/print:([^/]+).html$ /engine/print.php?do=static&page=$1 last;
        rewrite ^/rss.xml$ /engine/rss.php last;
        rewrite ^/sitemap.xml$ /uploads/sitemap.xml last;
    }

    location ~* \.(jpg|jpeg|gif|png|ico|swf|css|js)$ {
        expires             30d;
        add_header          Cache-Control public;
    }

## Тут установлен дополнительный пароль на админку
    location =/admin.php {
        auth_basic            "closed section";
        auth_basic_user_file  htpasswd;
        fastcgi_pass   unix:/tmp/fastcgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/tmp/fastcgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

Drupal

phpBB

via http://stackoverflow.com/questions/15299391/nginxphpfpm-rewrite-rules-not-working

location / {
    try_files $uri @rewrite;
}

location @rewrite {
    rewrite ^/$ /index.php last;
    rewrite ^/(forum|[a-z0-9_-]*-f)([0-9]+)(-([0-9]+))?\.html$ /viewforum.php?f=$2&start=$4 last;
    rewrite ^/(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?f=$2&t=$4&start=$6 last;
    rewrite ^/post([0-9]+)\.html$ /viewtopic.php?p=$1 last;
    rewrite ^/(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?f=$2&t=$4&start=$6 last;
    rewrite ^/([a-z0-9_-]*)/?(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?forum_uri=$1&t=$3&start=$5 last;
    rewrite ^/resources/[a-z0-9_-]+/(thumb/)?([0-9]+)$ /download/file.php?id=$2&t=$1 last;
    rewrite ^/post([0-9]+)\.html$ /viewtopic.php?p=$1 last;
    rewrite ^/active-topics(-([0-9]+))?\.html$ /search.php?search_id=active_topics&start=$2&sr=topics last;
    rewrite ^/unanswered(-([0-9]+))?\.html$ /search.php?search_id=unanswered&start=$2&sr=topics last;
    rewrite ^/newposts(-([0-9]+))?\.html$ /search.php?search_id=newposts&start=$2&sr=topics last;
    rewrite ^/unreadposts(-([0-9]+))?\.html$ /search.php?search_id=unreadposts&start=$2 last;
}

Discussion

Enter your comment. Wiki syntax is allowed:
 
linux/nginx/nginx_rewrite_dokuwiki.txt · Last modified: 2019/12/11 19:03 (external edit)