I’m trying to remove the file extension from the url of the static pages
sitename.com/page.php
→ sitename.com/page
I made it so that my wp url looks like this (if it matters)
sitename.com/wp/
→ sitename.com/
FTP looks like this:
- root directory
- static php files
- htaccess file
- wp folder
Adding this to .htaccess
doesn’t do anything
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
Current .htaccess
contents:
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php
ErrorDocument 403 /403.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
How do I achieve this by only adding a code in the .htaccess
file?
Thank you in advance!
2
Answers
I realized the files are getting overwritten so the only way I can go about it is to create individual folders for each static file (i.e., page/index.php) so that I can achieve this
sitename.com/page.php
→sitename.com/page
The steps to remove file extensions are:
#remove php file extension-e.g. https://example.com/file.php will become https://example.com/file
To remove .html extension use: