0

I want to remove .php from my files and if anyone writes .php not working like this:

www.example.com/home.php => www.example.com/home

if a user adds .php => not working or redirect to home

This is my .htaccess for URL:

RewriteRule ^home$ home.php
Joe
  • 4,877
  • 5
  • 30
  • 51
  • 1
    This looks like a duplicate of: http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess – MannfromReno Jan 13 '17 at 20:11
  • 2
    Possible duplicate of [Remove .php extension with .htaccess](http://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – Croises Jan 13 '17 at 20:14

2 Answers2

0
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

inside your .htaccess

walters
  • 13
  • 6
0

You must have apache active mod_rewrite module

The .htaccess file:

<IfModule mod_rewrite.c>
# Enable RewriteEngine
RewriteEngine on
RewriteBase /
RewriteCond% {SCRIPT_FILENAME}! -d
RewriteCond% {SCRIPT_FILENAME}! -f
 
# Rewrite URL requested by the user
# IN: ID-NAME
# Output: example.php? Id = ID
RewriteRule ^ ([0-9] +) \ - ([a-zA-Z0-9 -] *) $ example.php? Id = $ 1
</ IfModule>

Regards

juanitourquiza
  • 2,097
  • 1
  • 30
  • 52