Hide URL extension (.php)

Discussion in 'Site & Server Administration' started by cluongo18, Dec 17, 2011.

  1. #1
    On my website my pages are all .php extensions, and I was wondering how could I properly hide these in the browser.

    Example: mysite.com/page.php
    to: mysite.com/page

    I tried creating an HTACCESS file with this in it:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.*)\.htm$ $1.php [nc]
    Code (markup):
    but that didn't seem to work

    By the way this is a normal static (well dynamic) website, no CMS behind it
     
    Last edited: Dec 17, 2011
    cluongo18, Dec 17, 2011 IP
  2. VPS6NET

    VPS6NET Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #2
    I think you would need to setup an array with PHP that serves your content, so that your URLs will look like typical 'generated' URLs, like "domain.com/?p=page".

    It's not too hard to accomplish, just search Google for a tutorial.
     
    VPS6NET, Dec 17, 2011 IP
  3. cluongo18

    cluongo18 Member

    Messages:
    855
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #3
    Yea I already did that hence why I'm posting here looking for a better solution. All the tutorials I read off Google told me to create an HTACCESS file and that isn't working.

    But thanks anyways, if anyone has a solution or link to one I would appreciate it
     
    cluongo18, Dec 17, 2011 IP
  4. VPS6NET

    VPS6NET Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #4
    Ah, my apologies. In that case, I am not sure exactly what the problem is.
     
    VPS6NET, Dec 17, 2011 IP
  5. Stanker

    Stanker Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Did you try paste this line into your htaccess?

     
    Stanker, Dec 19, 2011 IP
  6. BarrettNetworks

    BarrettNetworks Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
     RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php
    Code (markup):
    This should work for you.
     
    BarrettNetworks, Dec 20, 2011 IP