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.

Need help with ReWrite, serious problem, thanks.

Discussion in 'Apache' started by Al Capone, Sep 22, 2005.

  1. #1
    Right now I am using this

    but I want to have
    to take people to
    with a space between the please and the help not a -

    I really appriciate anyones help on this matter, thanks in advance
     
    Al Capone, Sep 22, 2005 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    RewriteRule ^search/index.php?REQ=please help$ e-please-help.htm

    (Not sure if it'll work!) It's either a ? or & that would make it not work, or maybe even the space. And you might need to add a / in there.
     
    Nintendo, Sep 22, 2005 IP
  3. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Before all the other RewriteRules, add
    RewriteCond %{REQUEST_URI} ^e-please-help.htm$
    RewriteRule ^(.*)$  /search/index.php?REQ=please\%20help [NE,L]
    Code (markup):
    Not tried it but I think that should do it. The %20 should correctly get translated to a space

    hope it helps

    John
     
    johnt, Sep 22, 2005 IP
  4. Al Capone

    Al Capone Well-Known Member

    Messages:
    784
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    140
    #4
    Sorry about all the confusion, the term please help was just an example, i want any term to rewritten in that format, so could someone write what that would be, thanks in advance.
     
    Al Capone, Sep 22, 2005 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    RewriteRule ^e-(.*).htm$ /search/index.php?REQ=$1

    would work for both

    /e-please-help.htm
    and
    /e-please help.htm

    For anything where 'please help' is.

    You just have to make the script link they way you want it, or link to it on a static page the way you want it linked.
     
    Nintendo, Sep 22, 2005 IP
  6. Al Capone

    Al Capone Well-Known Member

    Messages:
    784
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    140
    #6
    The thing is, RewriteRule
    will take people from /e-please%20help.htm to /search/index.php?REQ=please%20help

    I want /e-please-help.htm to take people to /search/index.php?REQ=please%20help

    I don't want to have %20 in the rewritten url.

    Again, please note, please help is an example, I want it to work like this with anything.

    thanks in advance
     
    Al Capone, Sep 23, 2005 IP
  7. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #7
    As far as I know, a space in a URL will always be changed by the browser to %20, regardless of whether its a static link, rewritten or whatever. That's just how a space is encoded in URLs.

    However, your mod_rewrite is not redirecting the URLs, only rewriting them for internal use. So if someone type /e-please-help.htm into their browser's address bar, then that page name would stay in the address bar. They would never know that the actual page was /search/index.php?REQ=please%20help

    What I'm trying to say is that no-one would ever see a URL with %20 in it, only your search script would receive it like that. By using urldecode() you can have your script turn it back into a proper string with spaces.
     
    johnt, Sep 23, 2005 IP
  8. Al Capone

    Al Capone Well-Known Member

    Messages:
    784
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    140
    #8
    Yes, I understand that, but how would I go about making /e-word1-word2.htm rewrite the page /search/index.php?REQ=word1%20word2

    thanks in advance
     
    Al Capone, Sep 23, 2005 IP
  9. johnt

    johnt Peon

    Messages:
    178
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ah, I think I understand now.
    I think something like this will do it
    
    RewriteRule ^e-(.*)-(.*).htm$ e-$1\%20$2 [NE,N]
    RewriteRule ^e-(.*).htm$ /search/index.php?$1 [NE]
    
    Code (markup):
    That should recursively find all the "-"s after the first one and replace them with spaces. When there are no more, it should rewrite the whole lot to your search script.

    I hope ;)
     
    johnt, Sep 23, 2005 IP