• Lucid Dreaming - Dream Views




    Results 1 to 19 of 19
    1. #1
      Member icedawg's Avatar
      Join Date
      Jun 2003
      Gender
      Location
      right here
      Posts
      2,822
      Likes
      34

      Thumbs up

      I need help setting up a redirect so all our old topic links can point to their new homes. The old format was:

      dreamviews.com/forum/viewtopic.php?t=#####

      new forum:

      dreamviews.com/forum/index.php?showtopic=#####



      Everything I've tried using RedirectMatch has not worked.
      Each new day is a chance to turn it all around.

    2. #2
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by icedawg View Post
      I need help setting up a redirect so all our old topic links can point to their new homes. The old format was:

      dreamviews.com/forum/viewtopic.php?t=#####

      new forum:

      dreamviews.com/forum/index.php?showtopic=#####
      Everything I've tried using RedirectMatch has not worked.
      [/b]

      Using Apache mod_rewrite

      RewriteEngine on
      RewriteRule viewtopic.php\?t=([0-9]+) index.php?showtopic=$1

      Please note, not tested
      I think you need the slash in viewtopic.php\?t=
      as it's a regular expression, and so needs escaping
      (\_ _/)
      (='.'=)
      (")_(")

    3. #3
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Yeah, I've been trying to get Apache listening to my fantastically perfect regex for like the last half hour (pratically just like yours) but for some reason it isn't doing the redirection properly. It just ignores the rules I've set out:

      Code:
      RewriteEngine on
      RewriteRule ^forum/viewtopic\.php\?t=([0-9]+) forum/index.php?showtopic=$1 [R]
      It's okay when I remove the ?t= part, which is basically useless. And no, apparently I didn't need to escape the period even though it's a regex symbol. I tried it both with and without escaping and it didn't care. Whenever I try using the vodoo that is mod_rewrite I always find a million things not working quite how I expect. I think I blame Apache.

      It might just be better to make a viewtopic.php:

      Code:
      <?php
      header ( "Location: http://www.dreamviews.com/forum/index.php?showtopic=" . $_GET [ 't' ] );
      die ( "This is an old forum link. You are now being redirected to the topic on the new forums." );
      ?>
      Same result, less heartache!

    4. #4
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      visual example of it at work

      (\_ _/)
      (='.'=)
      (")_(")

    5. #5
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      I thought exactly the same thing. Regex Coach does the same here. Try it on Apache though. It doesn't work.

      I think mine (my Apache installation) is screwed. It should damn work. I think maybe my installation (possibly others I guess) bork out with the "?" character and anything beyond that. I've wrote a million mod_rewrite rules before, but they were all folder names going to PHP files with the query.

    6. #6
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Ack...
      sorry

      need to escape both the <dot> and <slash> in the regex
      as shown in the picture

      then change the &#092;1 to &#036;n, as apache has slightly different referencing notation

      Quote Originally Posted by Kaniaz View Post
      I thought exactly the same thing. Regex Coach does the same here. Try it on Apache though. It doesn&#39;t work.

      I think mine (my Apache installation) is screwed. It should damn work. It&#39;s defintely not my fantastically perfect regex, god forbid.
      [/b]
      hmmm, I can&#39;t test at the mo (at work)
      (\_ _/)
      (='.'=)
      (")_(")

    7. #7
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Heh yeah. Not that you can copy and paste from the picture though.

      EDIT: In the picture, what was with the regex code, namely the (12345) part? That should be [0-9]+. Not that I&#39;ve used Regex Coach&#39;s replace tab before so I have no idea.

    8. #8
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by Kaniaz View Post
      Code:
      RewriteEngine on
      RewriteRule ^forum/viewtopic&#092;.php&#092;?t=&#40;&#91;0-9&#93;+&#41; forum/index.php?showtopic=&#036;1 &#91;R&#93;
      [/b]
      Expression is wrong, here

      ^forum forces "forum" to be the first entry on the line
      when actually, you have "http://www.dreamviews.com/" before it

      (\_ _/)
      (='.'=)
      (")_(")

    9. #9
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      I know&#33; You&#39;d think so, but it doesn&#39;t care on my installation. Like I said, I think something is so whored out. Or I don&#39;t know so much about the start/end anchors as I should. The code will probably work on the server here and I&#39;ll look like a wannabe trying to protect his status of fantastically perfect Regex maker.

      EDIT: Yeah. When I use this Regex code:

      Code:
      RewriteRule ^forum/viewtopic&#092;.php forum/index.php?showtopic=3
      It&#39;ll redirect to that topic 3 just fine. Even though there&#39;s the start anchor. But redirecting constantly to topic three is totally useless (unless it&#39;s a topic full of naked women), so I add in the regex to capture the integer:

      Code:
      RewriteRule ^forum/viewtopic&#092;.php&#092;?t=&#40;&#91;0-9&#93;+&#41; forum/index.php?showtopic=&#036;1
      And, whammo, no more redirection for me. Just a "viewtopic.php could not be found", you know, because it isn&#39;t redirecting for crap. I must have enabled "WhoreOutRegex" in http.conf.

    10. #10
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      it seems the query string is seperated from the base url by apache
      and so the two need to treated seperately

      so, could someone test this out

      RewriteEngine on
      RewriteCond %{QUERY_STRING} ^t=([0-9]+)
      RewriteRule viewtopic.php index.php?showtopic=%1
      (\_ _/)
      (='.'=)
      (")_(")

    11. #11
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      I thought something funny was going on. I would&#39;ve got there if I had been bothered to keep going, I&#39;m sure.

      Yes, it works. Just checked it. Just shove all the /forum prefixes on ther eand it&#39;s good to go.

    12. #12
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Yay, I win, I win &#33;&#33;&#33;
      (\_ _/)
      (='.'=)
      (")_(")

    13. #13
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Okay. Your prize is a lifetime&#39;s supply of aniseed balls and Slimfast, the drink that lets you slim at accelerated speeds. That&#39;s right. Fast.

    14. #14
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      no need, no need

      I got meself one o&#39;these, instead

      (\_ _/)
      (='.'=)
      (")_(")

    15. #15
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Haha. Who the crap would wear that.

    16. #16
      Member icedawg's Avatar
      Join Date
      Jun 2003
      Gender
      Location
      right here
      Posts
      2,822
      Likes
      34
      thanks guys, but i still can&#39;t get it working. i&#39;ve tried:

      Code:
      RewriteEngine on
      RewriteCond %{QUERY_STRING} ^t=&#40;&#91;0-9&#93;+&#41;
      and then each of these:

      Code:
      RewriteRule /forum/viewtopic.php /forum/index.php?showtopic=%1
      RewriteRule ^/forum/viewtopic.php /forum/index.php?showtopic=%1
      RewriteRule viewtopic.php index.php?showtopic=%1
      so what&#39;s wrong?
      Each new day is a chance to turn it all around.

    17. #17
      Member Kaniaz's Avatar
      Join Date
      Jan 2004
      Gender
      Location
      England
      Posts
      5,441
      Likes
      9
      Could be almost anything I guess. Mod_rewrite is a can of worms&#33; Evil worms.

      So the condition isn&#39;t being triggered? Have you tried getting rid of the ^ anchor in the QUERY_STRING line? Just before t=([0-9]+). Not sure if that will help, but I don&#39;t know if an anchor should be there, so it may be worth a try.

      EDIT: That said, it worked on my test server. So I technically have no idea.

    18. #18
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      in which case, I&#39;d modify the viewtopic file, as Kaniaz said

      Code:
      &#60;?php
      if &#40;isset&#40;&#036;_GET&#91;&#39;t&#39;&#93;&#41;&#41;
      {
      header&#40;&#34;Location&#58; http&#58;//www.dreamviews.com/forum/index.php?showtopic=&#34; . &#036;_GET&#91;&#39;t&#39;&#93;&#41;;
      }
      else
      {
      header&#40;&#34;Location&#58; http&#58;//www.dreamviews.com/forum/index.php&#34;&#41;;
      }
      ?&#62;
      (\_ _/)
      (='.'=)
      (")_(")

    19. #19
      Member icedawg's Avatar
      Join Date
      Jun 2003
      Gender
      Location
      right here
      Posts
      2,822
      Likes
      34
      Alright, great. thanks both of you&#33;
      Each new day is a chance to turn it all around.

    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
    •