ZenphotoCMS Forum
Mod rewrite help request - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Mod rewrite help request (/thread-7188.html)



Mod rewrite help request - Joris - 2010-06-15

Hello,

I would like to change the url scheme to use 'portfolios' instead of 'gallery', i.e. the gallery page should display at /portfolios and an album with folder name 'some-album' should display at /portfolios/some-album.

I have specified the following in the .htaccess:

RewriteRule ^portfolios/?$ index.php?p=gallery [L,QSA] RewriteRule ^portfolios/([A-Za-z0-9_\-]+)/?$ index.php?album=$1 [L,QSA]
This works as intended, until I turn on 'mod rewrite' under Options > General:
The gallery page displays fine at /portfolios, but when I try to view an album at /portfolios/some-album I get the following message:

Quote:[b]Zenphoto Error:[/b] the requested object was not found.
Album: portfolios
Image: some-album
Page:
Any help would be greatly appreciated!




Mod rewrite help request - acrylian - 2010-06-15

This can't work. Just rename the "gallery" page of your theme to "portfolio" and you should be done. It is a so called "custom page", no need to change rewrite rules.

Since it is a custom page there needs also to be a /page in the url so you have /page/portfolio/ because otherwise Zenphoto thinks a top level album named /portfolio exists which does not.

Or you just make a toplevelalbum named portfolio and link to that directly.




Mod rewrite help request - Joris - 2010-06-15

Thanks a lot!

That was not exactly the solution I was looking for — I really don't want the /page/ part — but it did lead me to this workaround:

I renamed album.php to customalbum.php, and .htaccess now reads the following:
`
RewriteRule ^portfolios/?$ index.php?p=portfolios [L,QSA]
RewriteRule ^portfolios/([A-Za-z0-9
-]+)/?$ index.php?p=custom-album&title=$1 [L,QSA]
. Then added this line to the top of custom_album.php: $_zp_current_album = new Album($_zp_gallery, $_GET['title']);`

Thanks again!




Mod rewrite help request - acrylian - 2010-06-15

The /page part is needed so that Zenphoto is not confused. Of course if you can disable that via htaccess.
You should really do a sanitize($_GET['title']) for security.

Anyway, I still think it would be much easier to have a toplevel album "portfolio" to link to directly since then there would not be a /page (depends on your theme of course...)




Mod rewrite help request - Joris - 2010-06-15

Ah, you're right about the top level album. I didn't fully understand from your first post. That's definitely a more elegant solution.

Thanks again.

PS I (wrongly?) assumed the sanitize_path in the Album constructor would have been sufficient for security.




Mod rewrite help request - Joris - 2010-06-15

Donation on its way.




Mod rewrite help request - acrylian - 2010-06-15

You are right, I forgot there is already a sanitize_path. Well better double than nothing..;-)

Thanks for the donation.