All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			
		
			
				
	
	
		
			52 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
	
		
			1.4 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						||
author: einar
 | 
						||
categories:
 | 
						||
- General
 | 
						||
- Linux
 | 
						||
comments: false
 | 
						||
date: "2014-04-26T08:31:57Z"
 | 
						||
post_format:
 | 
						||
- Aside
 | 
						||
slug: notes-to-self-nginx-piwigo-rewrite-rules
 | 
						||
tags:
 | 
						||
- nginx
 | 
						||
- piwigo
 | 
						||
- rewrite
 | 
						||
title: 'Notes to self: nginx Piwigo rewrite rules'
 | 
						||
omit_header_text: true
 | 
						||
disable_share: true
 | 
						||
wordpress_id: 1315
 | 
						||
---
 | 
						||
 | 
						||
This was inspired by [this forum thread](http://piwigo.org/forum/viewtopic.php?id=20449) on the Piwigo forums. Set up rewrite rules in nginx where "piwigo" is the path the gallery lies in:
 | 
						||
 | 
						||
{{< highlight nginx >}}
 | 
						||
 | 
						||
location @rewrite {
 | 
						||
    rewrite ^/piwigo/picture((/|$).*)$ /piwigo/picture.php$1 last;
 | 
						||
    rewrite ^/piwigo/index((/|$).*)$ /piwigo/index.php$1 last;
 | 
						||
    # The following is needed for batch operations which use i.php
 | 
						||
    rewrite ^/piwigo/i((/|$).*)$ /piwigo/i.php$1 last;
 | 
						||
}
 | 
						||
 | 
						||
location /piwigo {
 | 
						||
    index index.php;
 | 
						||
    try_files $uri $uri/ @rewrite;
 | 
						||
}
 | 
						||
 | 
						||
location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
 | 
						||
    try_files $script_name = 404;
 | 
						||
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
 | 
						||
    fastcgi_param PATH_INFO $path_info;
 | 
						||
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 | 
						||
    include fastcgi_params;
 | 
						||
}
 | 
						||
{{< / highlight >}}
 | 
						||
 | 
						||
Lastly, add the relevant information to the Piwigo configuration (LocalFiles editor):
 | 
						||
 | 
						||
{{< highlight php >}}
 | 
						||
$conf['php_extension_in_urls'] = false;
 | 
						||
$conf['question_mark_in_urls'] = false;
 | 
						||
{{< / highlight >}}
 | 
						||
 |