Forum

Thread tagged as: Question, Problem

.php extension appears in frontend but not backend

Hi,

For some reason the .php extension doesn't show in the perch admin e.g. "example.com/perch/core/apps/content/" but does appear in my page e.g. "example.com/page.php".

Site URL: https://charthamvh.co.uk/

My .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^detail/([a-zA-Z0-9-/]+)$ /detail.php?s=$1 [L]
RewriteRule ^category/([a-zA-Z0-9-/]+)$ /category.php?cat=$1 [L]

# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

</IfModule>

Thanks in advance.

Michael Levett

Michael Levett 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Sorry, I'm not sure what you mean about not being able to see the PHP extension. Can you explain what you are expecting to see? Do you mean a particular page isn't showing up to edit?

Thanks for the reply,

Sorry my question wasn't written very clearly. What I was trying to say is: I want to remove the .php extension from my pages on the frontend and I'm not sure why; I am currently still getting the .php extension appear on the frontend of the site. However on the perch admin the .php extension does not appear; so if the .php extension isn't appearing on the backend, then why is it appearing on the frontend?

It's weird, if I go to https://charthamvh.co.uk/gallery for instance, then no .php but if I go to gallery via the nav .php is not removed. Should I just remove the .php from the link in the nav? Or shouldn't my .htaccess settings just remove the .php extension automatically?

I hope that makes more sense.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You need to manage whether you use the extension in your navigation. It wouldn't be removed by .htaccess. That's not how it works. You need to create the links you want and use the rewrite rules to make them work.