Need help with mod_rewrite

Discussion in 'Apache' started by wheel, Jun 11, 2006.

  1. #1
    Anyone willing to spoonfeed me a redirect I need? Mod_rewrite is just to complex to easily figure it out for a one-time rewrite :).

    I've taken over mozdex.com, which provides free open source search feeds. There's a bunch of people using the feed on an old URL or two. I need to redirect their search traffic over to the current api so that their websites aren't all broken (no way of contacting these people to ask them to move, so I need to do it for them).

    There are two URL's that are being used, difference of only a slash:

    ww.domain.com/opensearch/?querystring
    www.domain.com/opensearch?querystring

    I need to permanently move these two strings to:
    www.domain.com/open.jsp?querystring

    Help?
     
    wheel, Jun 11, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    domain.com/.htaccess

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^opensearch/?([^.]+)$ http://www.domain.com/open.jsp?$1 [R=301,L]
     
    Nintendo, Jun 12, 2006 IP
  3. wheel

    wheel Peon

    Messages:
    477
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you *very* much, I really appreciate that. It didn't quite work, but I think it's close enough that I can figure it out.
     
    wheel, Jun 12, 2006 IP
  4. mad-I.T.

    mad-I.T. Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi guys, im kinda new to SEO and mod_rewrite and i need help with my apache server in my computer, i've uncommented the ff:

    LoadModule rewrite_module modules/mod_rewrite.so and
    AddModule mod_rewrite.c

    then i wrote this on the .htaccess file:

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index.shtml$ index.php [L]

    i have the index.php file in http://localhost/samples/ directory

    but once i open http://localhost/samples/index.shtml , the browser displays a 404 Not Found Error.

    Am i missing something here? Thanks in advance =)
     
    mad-I.T., Jun 16, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^samples/index.shtml$ samples/index.php [L]

    if it's at domain.com/.htaccess

    And change

    http://localhost

    to an actual URL!
     
    Nintendo, Jun 16, 2006 IP
  6. mad-I.T.

    mad-I.T. Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It's working fine now nintendo thanks, how do i change http://localhost to an actual URL?
     
    mad-I.T., Jun 16, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #7
    Nintendo, Jun 17, 2006 IP
  8. mad-I.T.

    mad-I.T. Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    oh i see =)

    i asked you how to change the http://localhost to http://www.domain.com because i thought there was a way to reconfigure apache settings so that it would display http://www.domain.com without being online hehehe.

    well anyway, everything seem well as of the moment. Thanks a lot Nintendo. =)
     
    mad-I.T., Jun 17, 2006 IP
  9. sflc2000

    sflc2000 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Was using the sample on this post to attempt t solve a rewrite issue but it's throwing an Internal Server Errror. What we need to do is take something like:

    ...domain.com/query1/query2/web-page.html?12345
    (or, ?id=12345 even)

    and have it go to:

    ...domain.com/index.php?a=query1&b=query2&id=12345

    Here's the .htaccess snippet for the rewrite rule that throws the error:
    RewriteRule ^action/([0-9a-z/-]+.html?([^.]+) /index.php?a=display&b=$1&id=$2 [R=301,L]

    There could be different numbers of /a/b/c depth too, and ends in ?12345 or ?id=12345
     
    sflc2000, Sep 6, 2006 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #10
    Get rid of the ? in the final URL, and to make it look more like a normaL URL, move the number before .html.
     
    Nintendo, Sep 6, 2006 IP