SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: .htaccess -Redirecting Traffic to Main Content...

  1. #1
    SitePoint Zealot nwingate's Avatar
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess -Redirecting Traffic to Main Content...

    Howdy Folks,

    I run a vBulletin forum and I'm trying to turn off my archive and redirect traffic from my archive back to my main content.

    The URLs that I'm moving are:

    From:
    www.site.com/archive/index.php/t-1244.html

    To:
    www.site.com/showthread.php?t=1244


    I've tried a number of different things including
    RewriteEngine on
    RewriteRule ^archive/index.php/([0-9]+)/$ showthread.php?t=$1 [R=301, L]
    But non of them seem to work.


    Any ideas? Thanks in advance!

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,315
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    Nat,

    The problem that I see is the lack of correct regex. From your example URLs:
    Code:
    RewriteEngine on
    RewriteRule ^/?archive/index\.php/t-([0-9]+)\.html/?$ showthread.php?t=$1 [R=301, L]
    The /? is to take care of both Apache 1.x and 2.x (they ARE different in how they treat the leading / in a {REQUEST_URI}

    You omitted the t- and .html and added a trailing / in your regex. I've corrected the t- and .html and made the trailing / optional.

    You CAN learn how to do this, too, with articles like the one linked in my signature (as well as find other examples/uses for mod_rewrite code).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Zealot nwingate's Avatar
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the effort.
    I added the config you gave me and it caused a error 500 server error. Not sure if I did something wrong. I just copied and pasted what you gave me to my .htaccess file.

    Anyways, I'll keep looking and will check out your site. Thanks for the help.

    Any other ideas?

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,315
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    Nat,

    Sorry, I copied your code and didn't check the flags. My mistake as there should NOT be a space in there!
    Code:
    RewriteEngine on
    RewriteRule ^/?archive/index\.php/t-([0-9]+)\.html/?$ showthread.php?t=$1 [R=301,L]
    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Zealot nwingate's Avatar
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm.... now I get a 404 page not found?

  6. #6
    SitePoint Zealot nwingate's Avatar
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the whole thing:

    # -FrontPage-
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^siteurl\.com
    RewriteRule ^(.*)$ http://www.siteurl.com/$1 [R=permanent,L]
    RewriteEngine on
    RewriteRule ^/?archive/index\.php/t-([0-9]+)\.html/?$ showthread.php?t=$1 [R=301,L]

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,315
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    nw,

    First, please use [ code ] ... [ /code ] instead of a quote for your code as the quote is not repeated for me to respond to.
    Code:
    # -FrontPage-
    
    THAT is a major part of any problem - ugh! m$
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    protection
    Options +FollowSymLinks
    That should be in your httpd.conf
    RewriteEngine on RewriteCond %{HTTP_HOST} ^siteurl\.com RewriteRule ^(.*)$ http://www.siteurl.com/$1 [R=permanent,L]
    I would have used [R=301,L]
    RewriteEngine on
    NO need to repeat!
    RewriteRule ^/?archive/index\.php/t-([0-9]+)\.html/?$ showthread.php?t=$1 [R=301,L]
    If that doesn't find showthread.php, then showthread.php is not in the same directory as the archive directory (DocumentRoot).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  8. #8
    SitePoint Zealot nwingate's Avatar
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not using Frontpage... I must have copied an .htaccess file from somewhere else. Anyways...

    Your right that the files are in different locations. I'm doing the following
    From:
    www.site.com/archive/index.php/t-1244.html

    To:
    www.site.com/showthread.php?t=1244


    I get a 404 with the code suggested. Thanks for the effort.

    Anyone with a vBulletin forum out there that has turned off their archive and wanted to redirect the traffic to the main content? I can't believe I'm the first? I asked over at vbulletin.com and they had never done it before and had no help for me.

    Here is an example of a page that I would want to move to the main content.

    From:
    http://www.vbulletin.com/forum/archi.../t-142095.html

    TO:
    http://www.vbulletin.com/forum/showthread.php?t=142095

    Thanks

  9. #9
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,315
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    Nat,
    Code:
    # Change
    # RewriteRule ^/?archive/index\.php/t-([0-9]+)\.html/?$ showthread.php?t=$1 [R=301,L]
    # to
    RewriteRule ^/?forum/archive/index\.php/t-([0-9]+)\.html/?$ forum/showthread.php?t=$1 [R=301,L]
    Next time, SPECIFICITY, please, so we can get it right the first time.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  10. #10
    SitePoint Zealot nwingate's Avatar
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I think you misread my post. I was just giving an example of a site that used vbulletin but my folder is not /forum/. I stated the correct location in the first post and so I'm not sure what specifics I left out?

    Anyways, once I removed the forum folder location out of the code it worked. THANKS FOR THE HELP!


    For future reference... If anyone has a vBulletin based forum and wishes to turn off the archive and 301 redirect back to the main content here is the code:

    If your vbulletin install is in the root use this:

    RewriteEngine on
    RewriteRule ^/?archive/index\.php/t-([0-9]+)\.html/?$ /showthread.php?t=$1 [R=301,L]
    RewriteRule ^/?archive/index\.php/f-([0-9]+)\.html/?$ /forumdisplay.php?t=$1 [R=301,L]


    If your vbulletin install is in a /forum/ folder use:

    RewriteEngine on
    RewriteRule ^/?forum/archive/index\.php/t-([0-9]+)\.html/?$ forum/showthread.php?t=$1 [R=301,L]
    RewriteRule ^/?forum/archive/index\.php/f-([0-9]+)\.html/?$ forum/forumdisplay.php?t=$1 [R=301,L]
    Last edited by nwingate; Aug 21, 2007 at 07:53.

  11. #11
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,315
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    Nat,

    Thanks for that update!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    Updated mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

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
  •