how can hide .php suffix

Discussion in 'Linux Support: RHEL, CentOS, SUSE etc' started by Seyed Ali Roshan, Feb 7, 2016.

  1. hi
    i want to see /example instead of /example.php
    i done it by .htaccess before but now when i am using that rules , it dosent work :(
    how can i do it?
  2. no one help???
    i thought here was support place :((
  3. lsfoo

    lsfoo Administrator

    Hi Seyed,

    Apologies for the delay, I just wanted to verify that the fix works.

    First, enable rewrite rules for the virtual host. Then, try these rewrite rules:

    RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(.+)\.php$ $1 [R,L]
    RewriteCond %{REQUEST_URI} !(\..*|/)$
    RewriteRule ^(.*)$ $1.php [L]
    The first rule will redirect requests that end in .php to extension-less urls. The second rule will take all extensionless (and non '/' requests) and append .php to it so that the request will be handled by the php engine.

    I only tested this a few times, so it may block some other types of requests, so I recommend you try all the possible types of requests you may encounter.

    Please let me know how it goes,
  4. a lot of thanks
    it works sooooo good :)
    lsfoo likes this.
  5. lsfoo

    lsfoo Administrator

    Glad to hear it.


Share This Page