Results 1 to 2 of 2

Thread: Try to hide file extension in browser

  1. #1
    Join Date
    Jan 2014

    Try to hide file extension in browser

    Dear all,

    Thanks in advance.
    In dedicated linux server.I am developing the web site.
    i want to hide php file extension in the browser.
    i have made change in .htacess file which is located in /var/www/htm/mysite/ .

    Here is the file.
    vim .htaccess

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

    in the httpd.conf, mod_rewrite also enabled.

    vim /etc/httpd/conf/httpd.conf

    LoadModule rewrite_module modules/mod_rewrite.so

    But it is not working any more.

    Please suggest.

  2. #2
    Join Date
    Jul 2013
    You have to use this on your Htaccess :

    RewriteEngine On
    # Unless directory, remove trailing slash
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]
    # Redirect external .php requests to extensionless url
    RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]
    # Resolve .php file for extensionless php urls
    RewriteRule ^([^/.]+)$ $1.php [L]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
HTML5 Development Center

Recent Articles