getting rid of .php in URLs #510

Closed
opened 2026-10-05 00:01:44 +02:00 by adam · 4 comments
Owner

Have you ever thought about using mod_rewrite or a PHP routing class to get rid of the .php extension in the URLs?

This change could also be used to make URLs for GET requests more presentable.

Have you ever thought about using mod_rewrite or a PHP routing class to get rid of the .php extension in the URLs? This change could also be used to make URLs for GET requests more presentable. <!-- github-sync-id:190474461 -->
adam closed this issue 2026-10-05 00:01:44 +02:00
Author
Owner

Hi @tessus

You can already get rid of ".php" in URL, see configuration:

// php_extension_in_urls : if true, the urls generated for picture and
// category will not contain the .php extension. This will work only if
// .htaccess defines Options +MultiViews parameter or url rewriting rules
// are active.
$conf['php_extension_in_urls'] = true;

But if you have a PHP routing class to recommend, I would be happy to take a look :-)

Hi @tessus You can already get rid of ".php" in URL, see configuration: ``` // php_extension_in_urls : if true, the urls generated for picture and // category will not contain the .php extension. This will work only if // .htaccess defines Options +MultiViews parameter or url rewriting rules // are active. $conf['php_extension_in_urls'] = true; ``` But if you have a PHP routing class to recommend, I would be happy to take a look :-) <!-- github-comment-id:261706586 -->
Author
Owner

Hi @plegall

You can already get rid of ".php" in URL, see configuration:

Wow, that's great. I must have missed that in the documentation. When I think of it, I don't think there's a reference (single page) of config.php's settings, or maybe I just couldn't find it?
I could not find a description of templates (%gallery_title%) either. I only saw that one in the page banner field in the admin - options section.

But if you have a PHP routing class to recommend, I would be happy to take a look :-)

Ok, my answer might be a bit long, so bear with me. To answer your question: yes and no.

I thought of the micro framework Slim when talking about a routing class. It has great features and is lightweight. Then I had a look at Piwigo's source code. It seems that part of it follows the MVC pattern and I assume that you coded most of the classes yourself. In 2009 there were no great frameworks and they mostly came with too much junk anyway. I believe if you were to start over, you'd probably look into Laravel or their micro framework Lumen, since Laravel is maybe too much. Switching to a framework now is not feasible I would think, and it would probably take a long time.
There are a bunch of micro frameworks out there, many of which are dead. I'd probably go with Slim, but I've found a great blog post that describes several frameworks to match the author's requirements. At the end, 4 frameworks remain and are vetted in more detail. Slim and Lumen are in that last category.

However, this doesn't mean you can't use Slim's routing capability with your current code. (You could always start using more and more of the framework over time, if you wanted.) The documentation is great and it looks really easy to get going. Maybe you like it, who knows.

Hi @plegall > You can already get rid of ".php" in URL, see configuration: Wow, that's great. I must have missed that in the documentation. When I think of it, I don't think there's a reference (single page) of `config.php`'s settings, or maybe I just couldn't find it? I could not find a description of templates (`%gallery_title%`) either. I only saw that one in the page banner field in the _admin - options_ section. > But if you have a PHP routing class to recommend, I would be happy to take a look :-) Ok, my answer might be a bit long, so bear with me. To answer your question: yes and no. I thought of the [micro framework Slim](http://www.slimframework.com) when talking about a routing class. It has great features and is lightweight. Then I had a look at Piwigo's source code. It seems that part of it follows the MVC pattern and I assume that you coded most of the classes yourself. In 2009 there were no great frameworks and they mostly came with too much junk anyway. I believe if you were to start over, you'd probably look into [Laravel](https://laravel.com/) or their micro framework [Lumen](https://lumen.laravel.com/), since Laravel is maybe too much. Switching to a framework now is not feasible I would think, and it would probably take a long time. There are a bunch of micro frameworks out there, many of which are dead. I'd probably go with Slim, but I've found a great [blog post](https://modess.io/php-micro-framework-for-a-restful-api-part-1/) that describes several frameworks to match the author's requirements. At the end, 4 frameworks remain and are vetted in more detail. Slim and Lumen are in that last category. However, this doesn't mean you can't use Slim's routing capability with your current code. (You could always start using more and more of the framework over time, if you wanted.) The documentation is great and it looks really easy to get going. Maybe you like it, who knows. <!-- github-comment-id:261737565 -->
Author
Owner

Hi @tessus

I must have missed that in the documentation.

There is no such a page in the documention http://piwigo.org/doc actually. The include/config.inc.php is written to be self-explanatory and each variable can be overwritten thanks to plugin LocalFiles Editor. See more details on http://piwigo.org/doc/doku.php?id=user_documentation:use:features:conf_locale

I could not find a description of templates (%gallery_title%) either.

That's the only one as far as I remember.

In 2009 there were no great frameworks [...]

Piwigo codebase is much much older :-) Piwigo was started in 2001. Back then its name was PhpWebGallery.

Switching today on a framework would mean a huge work. Really huge. And to be frank, it would bring no improvement to end users, which is what matters most to me :-) But it doesn't mean we do all "by ourselves". Some piece of code are external libraries, like template engine, mailer, password handler, CSS minify, mobile device detector, random generator...

I took a quick look at Slim and indeed it seems interesting (and the documentation is very nice). I won't rush to use it, but I keep it in a corner of my mind ;-)

Hi @tessus > I must have missed that in the documentation. There is no such a page in the documention http://piwigo.org/doc actually. The include/config.inc.php is written to be self-explanatory and each variable can be overwritten thanks to plugin LocalFiles Editor. See more details on http://piwigo.org/doc/doku.php?id=user_documentation:use:features:conf_locale > I could not find a description of templates (%gallery_title%) either. That's the only one as far as I remember. > In 2009 there were no great frameworks [...] Piwigo codebase is much much older :-) Piwigo was started in 2001. Back then its name was PhpWebGallery. Switching today on a framework would mean a huge work. Really huge. And to be frank, it would bring no improvement to end users, which is what matters most to me :-) But it doesn't mean we do all "by ourselves". Some piece of code are external libraries, like template engine, mailer, password handler, CSS minify, mobile device detector, random generator... I took a quick look at Slim and indeed it seems interesting (and the documentation is very nice). I won't rush to use it, but I keep it in a corner of my mind ;-) <!-- github-comment-id:263583438 -->
Author
Owner

@plegall thanks for all the info.

I totally agree that switching to a framework would not be feasible (as I also mentioned in my previous comment).

Glad you think Slim might be useful. I just wanted to mention this micro framework, since I came across it a while back and was quite impressed. When I was talking about a routing class I had that framework in mind.

But using the config options you mentioned works perfectly, so we can close this issue. Cheers.

@plegall thanks for all the info. I totally agree that switching to a framework would not be feasible (as I also mentioned in my previous comment). Glad you think Slim might be useful. I just wanted to mention this micro framework, since I came across it a while back and was quite impressed. When I was talking about a routing class I had that framework in mind. But using the config options you mentioned works perfectly, so we can close this issue. Cheers. <!-- github-comment-id:263669500 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#510