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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts

    Question .htaccess : Hiding .php extensions in URL

    Hi

    I was wondering if there is anyway we can hide the .php extension in the URL using .htaccess?

    For example

    These URLs:
    Code:
    http://example.com/home.php
    http://example.com/welcome/contact-us.php
    http://example.com/home/support/email_us.php

    Should look like
    Code:
    http://example.com/home
    http://example.com/welcome/contact-us
    http://example.com/home/support/email_us

    Pls let me know if this is possible and how?


    Many thanks

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

    With this rewrite, http://www.example.com/home.php is the same as http://www.example.com/home
    Last edited by dhape; 09-21-2011 at 01:21 AM. Reason: editing
    “Computers are useless. They can only give you answers.”
    (Pablo Picasso) Where To Find Coupons and Video Testimonials

  • Users who have thanked dhape for this post:

    phantom007 (09-21-2011)

  • #3
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Thanks very much

  • #4
    New Coder
    Join Date
    Feb 2007
    Posts
    86
    Thanks
    0
    Thanked 2 Times in 2 Posts
    This should do it for all extensions:

    Code:
    Options +MultiViews

  • #5
    New to the CF scene
    Join Date
    Sep 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess hide url php

    Your code is copy my htaccess file but don't working.

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

    This above code is not working.
    Pls help me.


  •  

    Posting Permissions

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