Results 1 to 9 of 9

How to rewrite attachment thumbnail URLs?

This is a discussion on How to rewrite attachment thumbnail URLs? within the Troubleshooting forums, part of the vBSEO SEO Plugin category; I'm trying to rewrite my attachment thumbnail URLs from outside of a vBulletin Folder. The code I have right now ...

  1. #1
    Junior Member
    Real Name
    Wongod
    Join Date
    Feb 2006
    Posts
    6
    Liked
    0 times

    Arrow How to rewrite attachment thumbnail URLs?

    I'm trying to rewrite my attachment thumbnail URLs from outside of a vBulletin Folder. The code I have right now is
    Code:
    include_once 'includes/functions_vbseo.php';
    vbseo_get_options();
    vbseo_prepare_seo_replace();
    get_forum_info();
    
    vbseo_any_url('attachment.php?attachmentid='.$thread["attachmentid"].'&stc=1&thumb=1&d='.$thread["thumbnail_dateline"])
    Any help?

    Also, will this cause the images to be cached by the browser?

    Thanks

  2. #2
    Junior Member
    Real Name
    Wongod
    Join Date
    Feb 2006
    Posts
    6
    Liked
    0 times

    Attachment Rewrite Rules

    I'm trying to write a custom rule to rename thumbnail attachments. I have

    Code:
    '^attachment\.php\?attachmentid=(\d+)&stc=1&thumb=1&d=(\d+)&name=(.+)' => 'attachment/$1$2/$3'
    where name is pulled from the DB and put into the url. However
    Code:
    vbseo_any_url("attachment.php?attachmentid=217&stc=1&thumb=1&d=1164782277&name=202588730");
    just returns the url with no rewrite.

    Why doesn't this work. Is it because it's conflicting with a built in attachment rewrite rule?

  3. #3
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    169 times
    Hello Wongod,

    yes, Custom Rewrite Rules are not applied to default vBulletin scripts (those having URL formats defined by default in vbseocp).

    ** merged threads **
    Last edited by Oleg Ignatiuk; 11-29-2006 at 09:34 AM.

  4. #4
    Junior Member
    Real Name
    Wongod
    Join Date
    Feb 2006
    Posts
    6
    Liked
    0 times
    So is there any way to accomplish this?

  5. #5
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    169 times
    You can rename attachments script and then create CRRs for new filename (attachment2.php, for instance).

  6. #6
    Junior Member
    Real Name
    Wongod
    Join Date
    Feb 2006
    Posts
    6
    Liked
    0 times
    Thanks, so I tried it out and got the rewrite to work, but the redirect does not.

    Code:
     'http://www.domain.com/forums/'.vbseo_any_url("fpattachment.php?attachmentid=217&stc=1&thumb=1&d=1164782277&name=202588730.jpg");
     =
     http://www.domain.com/forums/attachment/2171164782277/202588730.jpg
    which is correct. However the rewritten address gives me the "Invalid Attachment specified." error.

    When I turn off the custom rewrite rule and use the original URL, the attachment loads correctly.

    What's wrong?

  7. #7
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    169 times
    Since both $1 and $2 are numbers in your case, you should separate them in rewritten URL, for instance:
    'attachment/$1-$2/$3'

  8. #8
    Junior Member
    Real Name
    Wongod
    Join Date
    Feb 2006
    Posts
    6
    Liked
    0 times
    Thanks Oleg! It works now. Do you happen to know if this will cause the images to get cached?

  9. #9
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    169 times
    Yes, but that depends on browser. You can send cache related http headers in the script to make sure it is cached (or not cached).

Similar Threads

  1. Attachment Rewrite BUG
    By webgroup in forum Bug Reporting
    Replies: 3
    Last Post: 07-01-2006, 12:01 PM
  2. Google Sitemap-Listing of old url's option-from 1.7
    By T2DMan in forum Member Articles
    Replies: 0
    Last Post: 04-02-2006, 08:46 AM
  3. Replies: 6
    Last Post: 01-07-2006, 10:35 AM
  4. vBSEO 2.0 RC7 Released
    By Juan Muriente in forum vBSEO Announcements
    Replies: 17
    Last Post: 09-08-2005, 11:00 PM

Posting Permissions

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