Simple (?) problem with removing .php extension

Discussion in 'Apache' started by Sorror, Oct 21, 2011.

  1. #1
    Hi guys,

    What I already know: how to remove .php extension from server files and then making every request to abc.com/info read by server as abc.com/info.php (thus executing files as php scripts without .php extension)

    What I would love to know: how to remove .php extensions from the url, but without removing it from server files. E.g.: there's a file called about.php, but users can type in their browsers just url/about and have my about.php served normally, just without the extension visible in browser address bar.

    Any ideas?

    Oh, and I obviously want to achieve it by using mod_rewrite and .htaccess file.

    I thought this would work:

    
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    
    Code (markup):
    It should work... But it doesn't. Still give 404 when trying abc.com/about with about.php existing within the directory.

    If you don't know how to do it, could you please try it on your Apache server? I have my Apache configured properly, so the code above should work (I don't see why wouldn't it). But it doesn't and I'm in a pickle...
     
    Last edited: Oct 21, 2011
    Sorror, Oct 21, 2011 IP
  2. Sorror

    Sorror Active Member

    Messages:
    376
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Oh Lord, above example works just fine. I accidentally restored httpd.conf version with 'AllowOverride none' inside, fml...
     
    Sorror, Oct 21, 2011 IP