0

I'm trying to remove the .php extensions from a site, which I have gotten to work. example.com/parent/child.php correctly changes to example.com/parent/child/

However, when going to example.com/parent.php it still rewrites properly but shows an index page.

I'm fairly new to .htaccess and Apache, so any help would be greatly appreciated!

Update from the comments

"My apologies, Its not letting me write the code. I grabbed it from this post:

Remove .php extension (explicitly written) for friendly URL"

RewriteEngine On
RewriteBase /

# remove enter code here.php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]


# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
Community
  • 1
  • 1
Frank
  • 71
  • 1
  • 3

0 Answers0