changing photo gallery URLs to static URLs

Discuss practical ways rearrange URLs using mod_rewrite.

changing photo gallery URLs to static URLs

Postby RodneyB » Mon Mar 28, 2005 7:57 pm

Hey guys,

I'm using a php photo gallery script that generates URLs like:

mywebsite.com/gallery/browseimages.php?c=2

and:

mywebsite.com/gallery/showimage.php?i=2

and:

mywebsite.com/gallery/search.php?do=searchresults&string=SEARCHTERM&catid=0&quicksearch=1


I'd like to have the urls turn into either a static directory looking structure (/gallery/cat/2) or a page looking structure (/gallery/category2.html). Even better would be the category name (/gallery/catname-category.html)

/gallery/showimage/2 or /gallery/showimage2.html for the second URL and

/gallery/searchresults/SEARCHTERM/category/0/quicksearch/1

for the search terms URL.

Could anybody help me out with this?

----

Also, when trying to register for this forum, I got the following error:

DEBUG MODE

SQL Error : 1062 Duplicate entry '0' for key 1

INSERT INTO rewrite_groups (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', 1, 0)

Line : 607
File : /home/myforums/public_html/includes/usercp_register.php
RodneyB
 

Postby Caterham » Wed Mar 30, 2005 5:51 am

I'd like to have the urls turn into either a static directory looking structure
you know that you have to change all links in your php script which generates the html output?

mod_rewrite can only take you back, if al static link was requested (i.e. the user clicks on a static link)

Even better would be the category name (/gallery/catname-category.html)
make sure, that you include the parameters in your url like /gallery/catname-category-browse-2.html
/gallery/catname-category-show-2.html
/.htaccess (in doc root) wrote:RewriteEngine On
RewriteRule ^gallery/[a-zA-Z_-]+-browse-([0-9]+)\.html /gallery/browseimages.php?c=$1 [L]
RewriteRule ^gallery/[a-zA-Z_-]+-show-([0-9]+)\.html /gallery/showimage.php?i=$1 [L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Wed Mar 30, 2005 9:17 am

Caterham wrote: you know that you have to change all links in your php script which generates the html output?


Yeah, I'm going to have to do some moderations to the script so that it shows the mod_rewrite URLs at least on the main page.

/.htaccess (in doc root) wrote:RewriteEngine On
RewriteRule ^gallery/[a-zA-Z_-]+-browse-([0-9]+)\.html /gallery/browseimages.php?c=$1 [L]
RewriteRule ^gallery/[a-zA-Z_-]+-show-([0-9]+)\.html /gallery/showimage.php?i=$1 [L]
[/quote]

Thanks for this! I'll give it a try later today!

Would this also work for the third URL I posted?

mywebsite.com/gallery/search.php?do=searchresults&string=SEARCHTERM&catid=0&quicksearch=1

Thanks again for the help!

--
Rodney
Guest
 

Postby Caterham » Wed Mar 30, 2005 10:42 am

no, it'll only work for your desired format

Even better would be the category name (/gallery/catname-category.html)
which I modified to /gallery/catname-category-browse-2.html for /gallery/browseimages.php?c=$1

/gallery/catname-category-show-2.html for /gallery/showimage.php?i=$1

The catname-categorycan be anything from the chars a-z, A-Z, the _ and -
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 45 guests

cron