1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

301 Redirect a vbulletin thread?

Discussion in 'Apache' started by Infiniterb, Mar 2, 2005.

  1. #1
    Infiniterb, Mar 2, 2005 IP
  2. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #2
    Infiniterb, Mar 2, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is how redirect is supposed to work - the first argument is supposed to be a path, not a URL. You need to use mod_rewrite instead.

    J.D.
     
    J.D., Mar 2, 2005 IP
  4. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #4
    Yeah, I figured the first part out about it needing to be a path and not the actual url. Thanks though.

    What's getting me now is that when I click on my link I get redirected, but the url in the address bar is now:

    http://www.domain.com/subdirectory/index.html?t=1234

    If possible, I'd like to eliminate the ? at the end. Any idea?
     
    Infiniterb, Mar 2, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    As I mentioned, you need to use mod_rewrite. Since you didn't define the logic you use to arrive at subdirectory from the original path, I can't give you an example, but you should find plenty examples on rewriting URLs in this forum. Just search for RewriteRule. Here's the link to Apache's rewrite guide:

    http://httpd.apache.org/docs-2.0/misc/rewriteguide.html

    J.D.
     
    J.D., Mar 3, 2005 IP
  6. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #6
    Ah, I see. Read the guide but still not seeing what I need to.

    Thanks for the help though. I do appreciate it.
     
    Infiniterb, Mar 3, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Well, you need to come up with some logic how to transform the original URL into a new one. For example, if you do something like this:

    RewriteRule ^some-path/([0-9]+)/([0-9]+)/?$ /my.php?id=$1&v2=$2

    you could serve URLs that look like /some-path/5/10 as /my-php?id=5&v=10.

    With mod_rewrite, you can also redirect URLs - if the first expression matches, redirect to a new URL, composed out of parts of the original one.

    J.D.
     
    J.D., Mar 3, 2005 IP
  8. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #8
    Yeah, I tried multiple methods, and was getting 500 internal errors.

    The url just needs to change from path/index.html?t=6740 to path/index.html. I just need to stip out the ?t=6740 (that number exactly). There will be no other ?t=xxxx number since the 301 redirect is leaving that in the url for some reason.

    I had tried:

    RewriteRule ^some-path/index.html$ /some-path/index.html?t=6740

    And was getting 500 errors. I tried adding [R], got a 500. Tried [L] and it worked, but the url was still using ?t=6740.
     
    Infiniterb, Mar 3, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #9
    try this:

    RewriteRule ^some-path/index.html\?t=6740$ /some-path/index.html

    If you need parts of the original path, use parenthesis and $n params. For example:

    RewriteRule ^([a-z0-9]+)/index.html\?t=6740$ /$1/index.html

    J.D.
     
    J.D., Mar 3, 2005 IP
  10. Infiniterb

    Infiniterb Well-Known Member

    Messages:
    1,314
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    168
    #10
    Hmm, that still didn't work. I'll PM you what I'm working with so you can see the "problem" in action.
     
    Infiniterb, Mar 3, 2005 IP