Image Gallery mod_rewrite

Discuss practical ways rearrange URLs using mod_rewrite.

Image Gallery mod_rewrite

Postby pietergroenewald » Sat Jun 21, 2008 3:41 am

Hi,

I have a image gallery installed and want to make the URL's rendered search engine friendly. I have read some guides on mod_rewrite but I am new to all this and to be honest, I am stuck :(

At the moment the layout is as follows:

domain.com/index.php?page=gallery (Shows album lists)
domain.com/index.php?page=gallery&album=animals (Shows photos in album animals)
domain.com/index.php?page=gallery&action=view&album=animals&image=1 (Shows image 1 when clicked)

Unfortunately the PHP image script, writes sub album URL's as follows:

domain.com/index.php?page=gallery&album=animals/cats

This causes the rewrite rule I have to not work :( Any way of escaping the / in the album name using mod_rewrite?

Can anyone help me rewrite the URL's to friendly URL's?

Ideally I want to to be like:

domain.com/gallery/
domain.com/gallery/animals/
domain.com/gallery/animals/1

Any help is very much appreciated!
pietergroenewald
 
Posts: 1
Joined: Sat Jun 21, 2008 3:24 am

Postby richardk » Sun Jun 22, 2008 2:30 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^gallery/?$ /index.php?page=gallery [QSA,L]
RewriteRule ^gallery/([^/]+)/?$ /index.php?page=gallery&album=$1 [QSA,L]
RewriteRule ^gallery/([^/]+)/([0-9]+)/?$ /index.php?page=gallery&album=$1&image=$2&action=view [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 91 guests

cron