Results 1 to 5 of 5

Thread: Run php files without .php extension -- WHAT'S THE TRICK I USED??

  1. #1
    Join Date
    Apr 2007
    Posts
    25

    Run php files without .php extension -- WHAT'S THE TRICK I USED??

    You know what I mean -- http://mydomain/myfile loads and runs myfile.php, without requiring or showing the .php extension.

    I did some trick, years ago, and I can't remember what it was. Added a line to some directadmin apache file, I think.

    Just did this ONE TIME, ONE PLACE, and every website did the trick.

    I have create cloned servers based on my original DA setup, and this trick works on all sites on all cloned servers.

    I have just set up a directadmin server from scratch however, and I CANNOT FIND THE TRICK that I used in my cloned servers.

    I have validated that the following files are identical on both servers
    Code:
    /etc/httpd/conf/httpd.conf
    /usr/local/lib/php.ini
    on a per site level I have validated that the site's .htaccess files are identical.

    I have validated that the da created httpd.conf files found in
    Code:
    /usr/local/directadmin/data/users/USERNAME
    are identical except for IP addreses, paths, etc.

    I cannot remember the trick I did? Can anyone help?

    Nemo

  2. #2
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,941
    Hello Nemo,

    I believe previously you achieved it with Multiviews enabled in Apache, which is disabled now by default. It's considered to of a high risk now.

    https://httpd.apache.org/docs/2.4/co...tml#multiviews

    The same behaviors can be safely achieved with mod_rewrite.
    Regards, Alex G.

    - You can hire me on www.poralix.com to work on your server
    - Follow and like @Poralix on Facebook

  3. #3
    Join Date
    May 2008
    Posts
    794
    Mod_rewrite is the correct solution for your case. You can add this in .htaccess file:

    RewriteEngine On
    RewriteRule something something.php [L]
    When you visit yourdomain.dom/something it will load yourdomain.dom/something.php

    Add more lines for more files.

  4. #4
    Join Date
    Apr 2009
    Posts
    2,232
    @zEitEr, On a default DirectAdmin Apache 2.4.38 install it works just fine using MultiViews in .htaccess. I have tested by adding this to .htaccess

    Code:
    Options +MultiViews
    And it works correct. You can then browse to www.yourdomain.tld/filename without any extension at the end.

  5. #5
    Join Date
    Apr 2007
    Posts
    25

    Final Answer

    Thanks to Alex and Ditto for your help.

    I wanted this option to work on all sites on my server, without having to go through adding to dozens of .htaccess files.

    The global solution was to modify

    /etc/httpd/conf/extra/httpd-directories.conf
    and to change the line
    Options -MultiViews
    to
    Options +MultiViews

    Works like a champ! Thanks guys.
    Nemo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •