treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Extensionless URLs for plain PHP site

  • Hi there

    I know how to do set it up in the .htaccess file for a WordPress installation, but how would one go about creating extensionless URLs for a plain PHP site?

    Some things you might need to know:
    • All pages (currently) reside in the root folder
    • So each page has a name like about-us.php or contact-us.php


    Thanks in advance.

  • .htaccess is the simplest route in any case...For normal php sites i use:


    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^/]+)/$ $1.php


    of course, you have to have Modrewrite enabled on your server...