2

Basically folder etc has files:

contact.php
help.php
news.php

How can I make /etc/contact direct to /etc/contact.php?

1

2 Answers 2

3
RewriteCond %{REQUEST_URI}.php -f
RewriteRule (.*) $1.php
1
  • The condition %{REQUEST_URI}.php -f will never (very unlikely) be successful, since REQUEST_URI is a URL-path, not a file-path. It should be something like: RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f instead. (And you should also include the L flag on this rule.)
    – MrWhite
    Aug 1, 2022 at 16:46
0

I solved this by using the code below. first you need to head over to cPanel and in the directory, create a new .htaccess file or open for edit the one you already have, then insert the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

However, I still have issues with the PHP sections. for example, domain.com/dashboard now works but domain.com/dashboard/users still shows a 404 but when I manually enter domain.com/dashboard/?pg=users it works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .