Nice urls with Apache's mod_rewrite Nice urls with Apache's mod_rewrite
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Nice urls with Apache's mod_rewrite

Started by JensBman, December 27, 2004, 08:29:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JensBman

Hi!

I saw one or two request of this but there were from like 2002-2003 so I thought its time to take it up again. The only problem I have with cpg right now is the url's. Its much nicer to tell a friend to go to www.backeman.se/gallery/miniscour04 than www.backeman.se/gallery/thumbnails.php?album=10, and url that they will never remember.

Im not sure how big trouble it is to implement it but I have seen a few very small gallerys have it so... Well, I just hope you will implement it soon.

Keep up the good work!!

Best regards,
Jenz

Tranz

I think the reason we can't do this is that not everyone has mod_rewrite access. It's nice to use such a URL but impractical when dealing with database-driven items at the scale that cpg does it. Who verbally tells people URLs that often anyway. People usually tell URLs via email/IMs.

Joachim Müller

TranzNDance is right (as always): putting this into coppermine's core code would result in coppermine not working for users on IIS and webhosting without mod_rewrite. I can see litlle point in narrowing down the number of users coppermine can have for the sake of just a nice-to-have feature. However, there are postings on mod_rewrite with coppermine on the mods board.
In other words: your request is turned down; you're recommended to use the mod instead.

Joachim

JensBman

Ahh, found it. Thanks!

Well, I agree with one fellow that said something about autodetection and so on but I can understand the reasons why you don't want to implement it.

I'll try the mod. Thanks for your help!

/Jenz

partypics

#4
First of all I would like to thank the CPG developers community for such a great software!
I have read this thread http://forum.coppermine-gallery.net/index.php?topic=69.0 and done the modifications posted by Oasis to make nice url's to users galleries - and it worked fine in CPG 1.3.2
Just wanted to add my little improvement:
in original code a url like www.somesite.com/someuser
would work fine, but a url like www.somesite.com/someuser/ (with an ending "/") would fail.
To correct this you can add a line in .htaccess, redirecting www.somesite.com/someuser/ to www.somesite.com/someuser before other lines.
I used this regexp and it worked fine:
RedirectMatch ^/([a-z0-9&_=]+)/$ /$1

The second step, I think, is to make url's look like this:
www.somesite.com/someuser/album_name to point to a specific album. Users would love it.
I thought, that a redirect like
RedirectMatch ^/([a-z0-9&_=]+)/([a-z0-9&_=]+)$ /thumbnails.php?album=$2
would work, but it does not in Apache 1.* because "?" is translated into "%3f" and you can't pass arguments to a redirected script. It seems to be an Apache bug, which have been fixed in Apache 2 (not sure about it though, read somewhere else).
RewriteRule works with this regexp, but not entirely suitable:
you are actually on www.somesite.com/someuser/thumbnails.php, not www.somesite.com/thumbnails.php and links dont work, css and images don't load correctly, etc.

Anyone has done it before? Any ideas would be very appreciated. Thanks.



PS
Sorry, it looks like I chose the wrong place for my post, please move it to appropriate topic  ::)