0

I've been trying to remove the .php endings from the my URLs with this code, but it's not working. This is my .htaccess file:

# Apache Rewrite Rules
<IfModule mod_rewrite.c>
 Options +FollowSymLinks
 RewriteEngine On
 RewriteBase /

  # Add trailing slash to url
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
 RewriteRule ^(.*)$ $1/ [R=301,L]

  # Remove .php-extension from url
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.php -f
 RewriteRule ^([^\.]+)/$ $1.php 

  # End of Apache Rewrite Rules
</IfModule>

I put that file into my public_html folder. For some reason it's still displaying example.com/index.php instead of example.com/index. Any clue why?

ok14
  • 1

1 Answers1

0

Try this

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