...

View Full Version : Help with .htaccess and multiple redirects/mod_rewrites



daniel981
06-07-2010, 07:18 PM
I have a couple php pages that depend on some variables that are passed along in the URL. From my understanding, spiders dont like to pick up the dynamically created pages, so I want to do some clean up with clean-urls.

for example, I want to take:
http://www.dsphotos.com/dev/photos.php?album=72157624045892193

and have it turn into:
http://www.dsphotos.com/dev/album/72157624045892193/

That I've actually got working fine with this in my .htaccess:

RewriteEngine On

RewriteRule ^album/([a-zA-Z0-9]+)$ photos.php?album=$1
RewriteRule ^album/([a-zA-Z0-9]+)/$ photos.php?album=$1

RewriteBase /dev/

Now what I'm trying to do is add another rewite rule. I would like to take:
http://www.dsphotos.com/dev/image.php?photo=4654314183

and turn it into:
http://www.dsphotos.com/photo/4654314183/

I tried adding this to my .htaccess file:

RewriteEngine On

RewriteRule ^album/([a-zA-Z0-9]+)$ photos.php?album=$1
RewriteRule ^album/([a-zA-Z0-9]+)/$ photos.php?album=$1

RewriteRule ^photo/([a-zA-Z0-9]+)$ image.php?photo=$1
RewriteRule ^photo/([a-zA-Z0-9]+)/$ image.php?photo=$1

RewriteBase /dev/

but when I click on the link for the image, it comes up with a 404 error.

Any ideas? Thanks!

daniel981
06-07-2010, 11:36 PM
I got it! Working on it, trial and error, I finally figured it out:


RewriteEngine On
RewriteBase /dev/

RewriteRule ^album/([a-zA-Z0-9]+)$ photos.php?album=$1
RewriteRule ^album/([a-zA-Z0-9]+)/$ photos.php?album=$1

RewriteRule ^photo/([a-zA-Z0-9]+)$ image.php?photo=$1
RewriteRule ^photo/([a-zA-Z0-9]+)/$ image.php?photo=$1


There was an error with the path on the page itself, not the htaccess.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum