URL rewrites and .htaccess

ptemples

Joined: 2008-08-12
Posts: 9
Posted: Thu, 2008-11-06 00:37

The following information is required to get an answer:
Get this information from the PHP diagnostic (in the configuration wizard).
Gallery URL (optional but very useful):
Gallery version: 1.5.9
Apache version: 2.2.6
PHP version (don't just say PHP 4, please): 4.4.7
Graphics Toolkit: n/a
Operating system: Red Hat Enterprise 5
Web browser/version (if applicable): n/a

I'm looking for a little help with mod_rewrite. I recently upgraded from an older version of Gallery to 1.5.9. The rewrite rules in .htaccess don't seem to cover this older URL generated by Gallery embedded inside of phpWebSite CMS (version 0.8.2):

http://example.com/mod.php?set_albumName=albun84&mod=gallery&include=view_album.php

This used to be a valid URL to an album named "albun84". I would have expected one of the Apache mod_rewrite rules to change this to something like:

http://example.com/mod/gallery/albun84

but it doesn't. Instead, the browser is directed to the top-level Gallery menu, or

http://example.com/mod/gallery

(The URL is NOT rewritten in the browser address field.)

I've taken several "stabs" at writing a rule to handle this URL, but none seem to work for me. Any ideas what sort of mod_rewrite rule might do the trick?

At present, the .htaccess inside of the gallery directory looks like this:

# BEGIN Gallery section
# (Automatically generated. Do not edit this section)
# Note: still under development, so format may change.
# If you edit this file, make a backup before runnng the Config. Wizard.

Options -Indexes +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mod/gallery/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)/([0-9]+)$ /mod/gallery/view_photo.php?set_albumName=$1&index=$2 [QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)/([A-Za-z_0-9\-]+)$ /mod/gallery/view_photo.php?set_albumName=$1&id=$2 [QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)/$ /mod/gallery/$1 [R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)$ /mod/gallery/view_album.php?set_albumName=$1 [QSA]
</IfModule>
# END Gallery section. Add User changes below this line

Thanks,

Phil

 
xjessie007

Joined: 2008-11-21
Posts: 3
Posted: Fri, 2008-11-21 11:32

I probably do not have the best answer, but if everything fails, this will help. You can always hardcode the rewrite rule, something like the following should work

RewriteRule ^albun84 /mod.php?set_albumName=albun84&mod=gallery&include=view_album.php [L,QSA]

---
http://www.maxi-pedia.com

 
ptemples

Joined: 2008-08-12
Posts: 9
Posted: Fri, 2008-11-21 14:44

Thanks, xjessie007.

As it turns out, I found my answer on another web site forum. Handling the "?" is a little more involved and requires the RewriteCond %{QUERY_STRING} statement in conjunction. Here is the rule that worked for me:

RewriteEngine On

RewriteBase /

# Rewrite the older Gallery/phpWebSite URLs to the newer Gallery format
RewriteCond %{QUERY_STRING} ^set_albumName\=([^&]+)\&mod\=gallery\&include\=view_album.php.*$
RewriteRule ^mod.php$ /mod/gallery/%1? [R=301]

Thanks for taking a shot at it, though.

-Phil