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.

Rewrite to forward a URL with a space

Discussion in 'Site & Server Administration' started by amanamission, Mar 12, 2008.

  1. #1
    Way back in the day, before I learned about Seo URLs, I was foolish enough to create a page with two words and no hyphen. The page has been redesigned, but the mod_rewrite rules I have been using to redirect pages are not working. I get the dreaded 500 when I use:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^Firstword Secondword\.htm$ http://www.site.com/firstword-secondword/ [R=301,NC,L]

    Which is based on code I've used to forward other pages on my domain.

    Naturally, the URL shows in the browser bar as site.com/Firstword%20Secondword
    but when I try that in the mod_rewrite, there is no effect.

    What am I doing wrong?
     
    amanamission, Mar 12, 2008 IP
  2. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have a feeling that percent signs may need to be escaped but I would need to check the documentation to be sure.

    You may also get somewhere by escaping the space...
     
    Ladadadada, Mar 13, 2008 IP
    amanamission likes this.
  3. amanamission

    amanamission Notable Member

    Messages:
    1,936
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    210
    #3
    Pardon my ignorance, but what do you mean by "escape the percent" or "space"?

    how would I do that?
     
    amanamission, Mar 13, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    Put a backslash before the space between firstword and secondword.
    firstword\ secondword
    Code (markup):
     
    joebert, Mar 13, 2008 IP
    amanamission likes this.
  5. amanamission

    amanamission Notable Member

    Messages:
    1,936
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    210
    #5
    That did the trick! Thanks and rep to the two of you!
     
    amanamission, Mar 13, 2008 IP