Treehouse: Grow your CSS skills. Land your dream job.

Extensionless URLs for plain PHP site

  • # April 21, 2012 at 3:56 am

    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.

    # April 21, 2012 at 6:05 am

    .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…

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.