Hide my php extension in url

Discussion in 'PHP' started by iseree, Jun 25, 2008.

  1. #1
    iseree, Jun 25, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Mod rewrite is what you want.

    Probably looking for a rule similar to this:

    RewriteRule ^(.+)$ /$1.php [L]
     
    Danltn, Jun 25, 2008 IP
  3. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That rule wouldn't allow any get parameters to be passed though.
     
    matthewrobertbell, Jun 25, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    It was just an example. And he didn't say he needed extra parameters ;)

    Dan
     
    Danltn, Jun 25, 2008 IP
  5. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Lol you're making it too difficult :p
    RewriteRule ^search(/?)$ search.php [NC,L]
    Will take search and search/ and make it pass to search.php
     
    projectshifter, Jun 25, 2008 IP
  6. Alex-Z

    Alex-Z Peon

    Messages:
    337
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for that, projectshifter
     
    Alex-Z, Jun 25, 2008 IP
  7. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    np man. rewrite is pretty easy for the basics. You just need to know (.*) (match anything), ([0-9]+) (match a series of numbers) and (/?) that allows a slash but doesn't make it mandatory. Otherwise it creates $1, $2, $3, etc based on each one of those you put in the left side. Cake ;)
     
    projectshifter, Jun 25, 2008 IP
  8. iseree

    iseree Peon

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thank you very much!!
    Run perfectly
     
    iseree, Jun 26, 2008 IP
  9. mz906

    mz906 Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    can you fill me in on what the [NC, L] do?
     
    mz906, Jun 26, 2008 IP
  10. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #10
    NC = no case (so SEARCH/, search/, SeArCh/ etc all work)
    L = last, it will not read any more rules and it'll end at this one and perform the action.
     
    projectshifter, Jun 26, 2008 IP
    Alex-Z likes this.
  11. ktshoppe

    ktshoppe Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    My php files are in root\go\ sub directory. Example I want root\go\godaddy when typed in address bar works as root\go\godaddy.php for all php files in root\go\ sub directory what code should I add in .htaccess. I am using godaddy hosting
     
    ktshoppe, Nov 3, 2010 IP