.htaccess Redirect Help

Discussion in 'Apache' started by digital1, Feb 28, 2006.

  1. #1
    I'm currently in the middle of changing my gallery software and also moving it to a different location on my site, example:

    http://gallery.domain.com/ to
    http://forums.domain.com/gallery/

    I'm currently using this code in my .htaccess file and it works great for the most part:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^gallery.domain.com
    RewriteRule (.*) http://forums.domain.com/gallery/$1 [R=301,L]
    Code (markup):
    Now although this does redirect to the new folder all well and good, if I'm looking at a particular picture on my gallery which is located at say:

    http://gallery.domain.com/photo.php?=pic123

    it will will redirect to:

    http://forums.domain.com/gallery/photo?pic=123

    Which is not what I want, mainly because the new gallery uses different variables and will simply be dead links. I would like any all old gallery URLs to point to the new gallery root folder (http://forums.domain.com/gallery/).

    In summary, I would like the URL I mentioned earlier (as well as a few other examples just make everything absolutely clear):

    http://gallery.domain.com/photo.php?=pic123
    http://gallery.domain.com/album.php?=album987
    http://gallery.domain.com/photo.php?=pic123&cat=007

    to redirect to my new gallery's root folder:

    http://forums.domain.com/gallery/

    Hope I made myself clear, looking back on what I wrote it looks quite complex! ;)

    I would appreciate any and all help, I will reward positive reputation to all those who contribute. Thank you very much in advance. :)
     
    digital1, Feb 28, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    RewriteRule ^photo.php?=([^.]+)$ http://forums.devilmaycry.org/gallery/photo.php?=$1 [R=301,L]
     
    Nintendo, Feb 28, 2006 IP
    poseidon likes this.