Help needed to rewrite dynamically_generated URLs

Using mod_rewrite to handle various content issues

Help needed to rewrite dynamically_generated URLs

Postby phpsoft » Wed Oct 14, 2009 7:26 pm

I need every help I can get to rewrite the URLs dynamically generated by a PHP photo album script.
These examples are how the URLs show on web browsers:

index.php?page=list-image&album=1 (The URL of "album 1" while I name the album "Tropical Islands") and index.php?page=list-image&album=2 (The URL of "album 2 while the name might be something like " Exotic Beaches" or "Beaches").

How can I rewrite the above-mentioned "album 1" URL to be: "Tropical_Islands/" and subsequent dynamically-generated albums to appear that way.

This is an example of how the image URLs show:
index.php?page=image-detail&album=1&image=1 (The URL of "image 1" of "album 1" while I name this image "Buddha Temple")

I want the image URLs to be in this form: "Tropical_Islands/Buddha_Temple/"

Can anyone please show me how to rewrite the album and image URLs in order to have search engine-friendly URLs. I have tried a few tricks I know, but nothing works. My inability to achieve this stemmed from my lack of knowledge. What I need is to tell me the exact lines to remove and giving me the code to replace them.

These are the two codes I've tried that didn't work:
Code: Select all
## mod_rewrite configuration
Options +FollowSymLinks

# Turn on the rewriting engine
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]

RewriteRule ^[a-zA-Z]$ index.php?page=list-image&album=$0
RewriteRule ^([a-zA-Z])\/$ /$1 [R]

RewriteRule ^([A-Z]+)([a-z)]+)([0-9)]+)\.html$ index.php?page=image-detail&album=1&image=$3

RewriteRule  ^([^/]+)/$ index.php?page=image-detail&album=1&image=$1

#Options -Indexes IncludesNOEXEC FollowSymLinks


Code: Select all
## mod_rewrite configuration
Options +FollowSymLinks

# Turn on the rewriting engine
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]

RewriteRule ^([a-zA-Z0-9_])(.html)?$ index.php?page=list-image&album=$1

RewriteRule ^([a-zA-Z0-9_])\/([a-zA-Z0-9_])(.html)?$ index.php?page=image-detail&album=$1&image=$2

#Options -Indexes IncludesNOEXEC FollowSymLinks


Which of the two files above looks better, so that I can concentrate on it and discard the other? Your help will be much appreciated.
phpsoft
 
Posts: 4
Joined: Wed Oct 14, 2009 7:15 am

Postby richardk » Thu Oct 15, 2009 2:14 pm

How can I rewrite the above-mentioned "album 1" URL to be: "Tropical_Islands/"

FAQ: How to change a numeric ID into a name/title.

and subsequent dynamically-generated albums to appear that way.

You have to edit the script so the new URLs are outputted by it.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby phpsoft » Sun Oct 18, 2009 9:28 am

Thanks Richardk for pointing me in the right direction. I'm reading those helpful topics to see if I can be able to accomplish it on my own.
phpsoft
 
Posts: 4
Joined: Wed Oct 14, 2009 7:15 am

Postby richardk » Mon Oct 19, 2009 10:57 am

You can/should ask questions if you need help.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 0 guests

cron