.htaccess to make name.com/?word=hello into name.com/hello

Discussion in 'Apache' started by nethelp, Dec 17, 2009.

  1. #1
    Hello!

    I am having an issue with a .htaccess file in order to convert name.com/?word=hello into name.com/hello, can any one offer a suggestion if this is possible? I've been looking everywhere and I couldn't find much to solve this issue...

    My site is kind of search engine dictionary using ajax to display results from search but I want to offer my visitors the option that when they go to my name.com/keyword to show the description, currently it works only with name.com/?word=keyword

    Thank you in advance!


    P.S. name.com is a fictive domain, it's not actually my real domain.
     
    nethelp, Dec 17, 2009 IP
  2. iama_gamer

    iama_gamer Active Member

    Messages:
    404
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    well does your site have only an index page?
    else i see a problem with such a generic statement.

    suppose someone wants to view someother page u may have assume "aboutus.html" then it gets redirected to name.com/?word=aboutus.html

    it gets slightly complex is you want to conditionally filter this out. What i suggest is u make name.com/word/keyword redirect to name.com/?word=keyword

    in this case the redirect is

    RewriteRule ^word/([^/]+) http://name.com/?word=$1
     
    iama_gamer, Dec 17, 2009 IP
  3. jedi.knight

    jedi.knight Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try the following. That way, if the file actually exists it will not be rewritten. For example, if there is a file /foo.jpg, it will not become /?word=foo.jpg.

    
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ?word=$1 [L,QSA]
    
    Code (markup):
     
    jedi.knight, Dec 20, 2009 IP
  4. nethelp

    nethelp Peon

    Messages:
    389
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you both! I have solved the issue.
     
    nethelp, Dec 22, 2009 IP