Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: .htaccess Redirection Problems

  1. #1
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default .htaccess Redirection Problems

    Hello everybodies!
    I've created a dynamic image that my website users can put in their forum signature, but most forums don't support a .php file as an image.
    The image is http://cybergeorge.freehostia.com/gr...r/?user=George (actually index.php?user=George), and I wanted it so that when the user types http://cybergeorge.freehostia.com/gr...tar/George.gif it will redirect to the original file (George.gif doesnt actually exist).
    I tried using a .htaccess file, but George.gif AND all other files (existent or not) come up with 500 Internal Server Error.
    The contents of the .htaccess file is:
    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.+)\.gif$ index.php?user=$1 #[r=301,nc]
    I'm pretty good at PHP, but fairly new to .htaccess. Could someone help me please?

  2. #2
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone? No?

  3. #3
    Join Date
    Oct 2006
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nope. Doesn't look like it. Not very many people on here know .htaccess that well, aside from accompaniments to php-based webpage functions. I only very recently learned what it is. Try the PHP forums. Or ask Twey.

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    You could just use the single line .htaccess Redirect rule.

    Code:
    Redirect /olddirectory/oldfile.html http://yoursite.com/newdirect
    This is important to note the 3 separate parts, the command (Redirect), the old file location and the new file location. The new file location MUST be a complete url, while the old one can be a partial. This is also all on one line with each of the 3 parts separated by a single space.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeh, but it needs to be partial on the source and the destination URLs, because George.gif is meant to redirect to index.php?user=George, and Blah.gif is meant to redirect to index.php?user=Blah aswell.

  6. #6
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think the regexp is wrong, (.+) specifically, anyway, from what I use and works:
    Code:
    RedirectMatch /(.*).gif http://yoursite.com/index.php?user=$1
    if the * is too radical, just make it to [0-9a-zA-Z_]

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by George1024 View Post
    Yeh, but it needs to be partial on the source and the destination URLs, because George.gif is meant to redirect to index.php?user=George, and Blah.gif is meant to redirect to index.php?user=Blah aswell.

    If 'Me's advice doesn't help, how many images do you have that need redirecting? Because you can use the single line one like I showed for each file, being very specific for each one. However, if you have a butt-ton of them it would be pointless
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeh, every user that signs up to my website gets their own dynamic image so that wouldn't really work.

    Me's advice was the closest I've got to success
    But it redirects to http://cybergeorge.freehostia.com/greenhat/avatar/index.php%3fuser=greenhat/avatar/George instead of http://cybergeorge.freehostia.com/greenhat/avatar/index.php?user=George.
    I tried removing the url in the .htaccess file
    Code:
    RedirectMatch /(.*).gif http://cybergeorge.freehostia.com/greenhat/avatar/index.php?user=$1
    But that just comes up with the Internal Server Error again.

  9. #9
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    try doublequotes in redirect then:
    Code:
    RedirectMatch /(.*).gif "http://cybergeorge.freehostia.com/greenhat/avatar/index.php?user=$1"

  10. #10
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmmmmmmm, the quotes didn't seem do change anything.

Bookmarks

Posting Permissions

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