Announcement

#16 2021-02-01 02:09:44

simonjonnemeth
Member
2021-01-06
11

Re: Solved: how to generate friendlier urls

I'm not sure this works with the latest version. I just get error 404 when I try to access any of my catagories.

Offline

 

#17 2021-09-09 18:38:41

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

Two notes:

1. All changes documented in this thread work with Piwigo 11.5.0 (as far as I can tell).

2. There is a new addition to the Rewrite directives (and maybe in an .htaccess file). (No new changes to the .php files) The complete Rewrite directives are shown below with the new change in boldface, and must be presented in the following order exactly:

##################################
#    These rules will filter and recode short uri's back to long:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

#  do not change any uri with ".php" in it:
    RewriteRule ^(.+)\.php(.*)$ - [L]

#  do not change empty (Home) uri:
    RewriteRule ^$ - [L]

# redirect incoming search picture result uri to its original long uri:
    RewriteCond %{REQUEST_URI} ^/(.*)/search/(.*)$
    RewriteRule ^/([a-zA-Z0-9_-]+)/search/([a-zA-Z0-9_-]+)$ /picture.php/$1/search/$2 [NC,NE,L]


# redirect search uri (in the form "/search/..." to its original long uri):
    RewriteCond %{REQUEST_URI} ^/search/(.*)$
    RewriteRule ^/search/([a-zA-Z0-9_-]+)$ /index.php/search/$1 [NC,NE,L]

# redirect incoming short picture uri (in the form "/961/album-5-bangkok") to its original long uri:
    RewriteCond %{REQUEST_URI} !^(.*)\.php(.*)$
    RewriteCond %{REQUEST_URI} ^/([0-9]+)/([a-zA-Z0-9_-]+)$
    RewriteRule ^/([0-9]+)/([a-zA-Z0-9_-]+)$ /picture.php/$1/category/$2 [NC,NE,L]

#  redirect incoming short category uri (e.g. "/album-5-bangkok", no pagination) back to its original long uri:
    RewriteCond %{REQUEST_URI} !^(.*)\.php(.*)$
    RewriteRule ^/([a-zA-Z0-9_-]+)$ /index.php/category/$1 [NC,NE,L]
 
#  redirect incoming short category uri (with pagination) back to its original long uri (!! thanks to user "pre"):
    RewriteCond %{REQUEST_URI} !^(.*)\.php(.*)$
    RewriteCond %{REQUEST_URI} ^(.*)start-([0-9]+)$
    RewriteRule ^/([a-zA-Z0-9_-]+)/start-([0-9]+)$ /index.php/category/$1/start-$2 [NC,NE,L]
##################################

Offline

 

#18 2022-01-30 10:27:35

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

I confirm this hack also works with Piwigo 12.2.0.

Offline

 

#19 2022-11-02 08:02:22

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

Confirmed to also work in PWG 13.1.

Offline

 

#20 2023-02-26 21:01:31

Nigel-Aves
Member
2015-09-22
63

Re: Solved: how to generate friendlier urls

I've been trying to get this remarkable workaround / enhancement working on PIWIGO 13.6.

I tried the PHP portion first, one thing I immediately noticed is that the "insertion line number" are now off by about 7 or 8 lines. restarted  FPM.

Site opens correctly but when I click on an Album, the URL looks correct (from the php changes), but the display never changes and never goes into the sub-Albums / or thumbnail page. (I also tried with .htaccess changes and Allow Overrides All)

If anyone has a clue what I should try, please drop a line.

PIWIGO 13.6 / PHP 8.1 / Elegant Theme / Ubuntu Server / Apache with FPM

p.s. With the ability to trigger this in the interface and officially supported, it would be a great enhancement to PIWIGO.

Offline

 

#21 2023-02-26 22:03:57

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

Hello Nigel-Aves,

I'm not sure what the problem is with your upgrade. About a week ago I upgraded to PWG 13.5, and got these hacks to work without any additional changes beyond those mentioned in this thread. And just today I made the same changes on a 13.6 upgrade and it works fine.

I don't know how many versions you are jumping over to get to 13.6, but I'm sure there have been some changes to the file ../include/functions_url.inc.php since this hack was originally written. So, it's best not to use line numbers as your basis for where to make the insertions of new code... Those may change over the many versions. Rather, look for the actual code in the old lines which should precede the new ones, and use that as your guide where to insert the changes.

Btw, I used BBEdit to compare versions 13.5 and 13.6 of the unmodified functions_url.inc.php file, and it reports the two are identical. Thus, if you got it to work on 13.5 you should be able to just copy over the file from 13.5 and ue it directly in 13.6. I am not sure if this would work with previous versions of the file, though.

That's all I can think of right now. Good luck!

Offline

 

#22 2023-02-26 22:28:07

Nigel-Aves
Member
2015-09-22
63

Re: Solved: how to generate friendlier urls

@ahtoagah

Thanks for the write up. I did make sure that the php inclusions were in the right place!.

Quick question. Are you using php 7.4 or PHP 8.x?

Only reason I ask is that  PHP 8.x stopped " $conf['php_extension_in_urls'] =false; " from working, and it exhibits very similar behaviour (not showing sub-albums / thumbnails).

I did put in an enhancement request to integrate this " fix " into the main product. I'm pretty sure people would love this as an option.

Offline

 

#23 2023-02-27 06:33:07

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

I am using the same setup as you: PWG 13.6, php8.1, elegant theme. I can't think where the problem might be. You could try to clear all your caches (Administration >>Tools >>Maintenance), although that most often works only for template changes. Maybe your browser cache, too, or perhaps try a different browser.

Is anyone else in this forum having this problem with PWG 13.6?

Offline

 

#24 2023-02-27 11:12:15

erAck
Only trying to help
2015-09-06
2023

Re: Solved: how to generate friendlier urls

Nigel-Aves wrote:

Only reason I ask is that  PHP 8.x stopped " $conf['php_extension_in_urls'] =false; " from working

That's simply not true. It works with PHP 8.0 at least. Might be it doesn't work with the convoluted .htaccess rewrites here.


Running Piwigo at https://erack.net/gallery/

Offline

 

#25 2023-02-27 13:48:57

BigIsland270972
Member
Norway
2022-03-15
374

Re: Solved: how to generate friendlier urls

I'm in :) Is this hack suppose  to also remove the index.php ?
because that is currently present in my browser.

https://www.fotoarkiv.no/index.php/category/c
:-):-)

Last edited by BigIsland270972 (2023-02-27 13:49:17)


Piwigo 14.0 | https://fotoarkiv.no | https://foto.arki.vet | http://Bergen.gallery  | http://Ålesund.gallery | http://geiranger.gallery | http://fjord.photos | http://foto.oslo.no
Apache | PHP 8.1 | MariaDB

Offline

 

#26 2023-02-27 14:05:41

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

Yes, it should replace anything with the phrases "index.php", "picture.php" and "category" as part of the URI with something friendlier (based on the category name).

Hope this helps. Any other improvements you can make are welcome.

Offline

 

#27 2023-02-27 14:08:56

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

Offline

 

#28 2023-02-27 16:51:01

Nigel-Aves
Member
2015-09-22
63

Re: Solved: how to generate friendlier urls

@erAck

Might be it doesn't work with the convoluted .htaccess rewrites here.

My .htaccess is not convoluted! ( :) ) The only entries in it are "AcceptPathInfo On"  and "Options +MultiViews".

This feature stopped working (for me) when I went to PIWIGO 13 and php8. There were no web site changes made in vhost or .htaccess. I remember when I first mentioned it the only reply I had was "go back to php 7.4. - Which made me assume that there was a problem that needed looking at.

If this was an incorrect assumption then I need to look elsewhere for the solution, but I've looked through my vhost settings and nothing stands out at me.

Last edited by Nigel-Aves (2023-02-27 16:52:03)

Offline

 

#29 2023-02-27 17:22:20

ahtoagah
Member
2019-01-25
23

Re: Solved: how to generate friendlier urls

No, your htaccess is not convoluted... rather, it's *MY* original series of rewrite statements which I created in order to make the new URLs work in piwigo which is "convoluted". Certainly, if the commenter has any suggestions how to make them less convoluted, I would be glad to hear them.

I remember, too, that the change from php7.4 to 8.x created some problems for me... I don't *think* those problms are related to the URL rewrite problem here, but piwigo is sufficiently complicated (I won't say convoluted) that I wouldn't be surprised if they were somehow connected. I posted my own voodoo solutions to those elsewhere in this forum. Maybe some of those, as well as several others who wrote about their own transition to php8 might give you some help.

Having said that, I also remember choosing to stay on php7.4 for quite some time until I had my php8 problems worked out. And in fact, php7.4 is very solid and gave me what I needed back then. I only upgraded piwigo+php8 just because it was there, not because I *HAD* to. 8-)

One other thing I can think of... When I was creating the original hack, I recall tht I couldn't get it to work as a separate .htaccess file, and decided to incorporate all the statements inside my virtual server statements. And that worked for me, although I don't know why. Maybe that magic might work for you, too.

Offline

 

#30 2023-02-27 22:01:17

BigIsland270972
Member
Norway
2022-03-15
374

Re: Solved: how to generate friendlier urls

Got it working not currently using it. All worked great exept TAGS, guestbook and EvilBlog. also not working latest images (PWGStuff block) without a category. (flat)

PHP 7.4
Apache 2

Last edited by BigIsland270972 (2023-02-27 22:10:05)


Piwigo 14.0 | https://fotoarkiv.no | https://foto.arki.vet | http://Bergen.gallery  | http://Ålesund.gallery | http://geiranger.gallery | http://fjord.photos | http://foto.oslo.no
Apache | PHP 8.1 | MariaDB

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact