Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with .htaccess and multiple redirects/mod_rewrites

    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.p...57624045892193

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

    That I've actually got working fine with this in my .htaccess:
    Code:
    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:
    Code:
    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!

  • #2
    New Coder
    Join Date
    Oct 2006
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got it! Working on it, trial and error, I finally figured it out:

    Code:
    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.
    Last edited by daniel981; 06-07-2010 at 10:38 PM. Reason: Oops, hit submit too soon...


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •