Simple Mod Rewrite Question (site.com/string to site.com/?string)

Discussion in 'Apache' started by ColorWP.com, Feb 15, 2010.

  1. #1
    Hello.

    I am trying to figure out how do I make my server show pages in this format:
    When server side those will be translated correspondingly to:
    Also if a user enters the second option in the browser (site.com/?page1), he should be redirected to the main URL at site.com/page1.

    Currently I use this:
    RewriteEngine on
    RewriteRule ^([A-Za-Z0-9]+)$ /?$1
    Code (markup):
    But I keep getting a 500 Internal Server Error.
     
    ColorWP.com, Feb 15, 2010 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You are probably getting the HTTP 500 error due to A-Za-Z. That can be rewritten as A-Za-z or simply A-z, but it still won't detect the . in .html

    Instead try:

    RewriteRule ^([^/]+)$ /?$1 [L]
    Code (markup):
     
    chadsmith, Feb 15, 2010 IP
  3. ColorWP.com

    ColorWP.com Notable Member

    Messages:
    3,120
    Likes Received:
    100
    Best Answers:
    1
    Trophy Points:
    270
    #3
    I still get a 500 error with this in my htaccess:
    The error appears in both cases:
    site.com/?page or site.com/page
     
    ColorWP.com, Feb 19, 2010 IP