======Hotlinks and HTACCESS in Piwigo 2.4====== ====Presentation==== Piwigo 2.4 introduces the feature multizise, this includes many technical changes, especially in the filesystem : Before 2.4 the galleries and upload folders looked like this : +--Album +--pwg_high | |-mg_3663.png | |-mg_3664.png | \-mg_3665.png +--thumbnail | |-TN-mg_3663.png | |-TN-mg_3664.png | \-TN-mg_3665.png |--mg_3663.png |--mg_3664.png \--mg_3665.png Now in 2.4 we keep only one version of each photo (the original file, equivalent to old //pwg_high//) : +--Album |--mg_3663.png |--mg_3664.png \--mg_3665.png The direct consequences are : * the hotlink on the "web size" becomes a hotlink on the original * the hotlink on the HD no longer works * the hotlink on the thumbnail no longer works To solve this issue Piwigo tries to create or modify the .htaccess file on the root of your installation. This file contains some url rewrite rules informing your host that links to pictures had changed. ====Upgrade procedure==== If for some reason Piwigo can't create or modify the file you will have to edit it manually. Before do that think if you need it : if you are sure nobody hotlinks your pictures you can just ignore the following steps. - First of all, navigate to your Piwigo installation folder with a FTP client - If you don't see a file named **.htaccess** (with the first dot) create it - Now open this file with a text editor like Notepad (not complex a editor like Microsoft Word) - If it's a previously existing file, be careful there is not **RewriteEngine off** into it, otherwise you have to modify it into **RewriteEngine on** or the following will break your website. - Add it the **.htaccess** file these lines with some modifications : * on lines 5 and 6 modify **thumbnail** by the content of your local **$conf['dir_thumbnail']** if you have one * on lines 5 and 6 modify **TN\-** by the content of your local **$conf['prefix_thumbnail']** if you have one * on lines 13 and 15 modify **localhost** by your hostname without //http// or //www// (example: **my\-website\.com**) * CAUTION: if you have hyphens in all these values prepend them with a anti-slash (**TN-** becomes **TN\-**), you must also escape dots RewriteEngine on ## redirect <2.4 thumbnails hotlinks to i.php RewriteRule ^upload/(.*)/thumbnail/TN\-(.*)\.([a-z0-9]{3,4})$ i.php?/upload/$1/$2-th.$3 [L] RewriteRule ^galleries/(.*)/thumbnail/TN\-(.*)\.([a-z0-9]{3,4})$ i.php?/galleries/$1/$2-th.$3 [L] ## redirect <2.4 high-def hotlinks to original file RewriteRule ^upload/(.*)/pwg_high/(.*)\.([a-z0-9]{3,4})$ upload/$1/$2.$3 [L] RewriteRule ^galleries/(.*)/pwg_high/(.*)\.([a-z0-9]{3,4})$ galleries/$1/$2.$3 [L] ## redirect <2.4 low-def hotlinks to i.php RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost/.*$ [NC] RewriteRule ^upload/(.*)/(.*)\.([a-z0-9]{3,4})$ i.php?/upload/$1/$2-me.$3 [L] RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost/.*$ [NC] RewriteRule ^galleries(.*)/(.*)\.([a-z0-9]{3,4})$ i.php?/galleries/$1/$2-me.$3 [L] - Now old hotlinks should we correctly redirected