Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Removing .php extension for first directory only

    I have my .htaccess file set up to omit .php extensions from URLs. For instance:

    mysite.com/page
    mysite.com/item
    mysite.com/about

    Read from:

    mysite.com/page.php
    mysite.com/item.php
    mysite.com/about.php

    Which is great; however, I use the remaining part of the URL for parameters, which I want to be ignored. For instance, I want:

    mysite.com/item/1234567890/a-product

    To read from:

    mysite.com/item.php

    Rather than:

    mysite.com/item/1234567890/a-product.php

    Any idea how I can accomplish this in .htaccess? Here is my current .htaccess file:

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

  • #2
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    If you can have a .htaccess in each directory then create a .htaccess for the directories you don't want to omit the .php and turn RewriteEngine off.

    Code:
    RewriteEngine Off


  •  

    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
    •