.httaccess not hidden php control access not work

Viewed 58

i have this code to control access to some files and prepend some rule/Config files in php... i am trying to hide php extencion from URL but not work and send error 404.

URL test access used:

http://www.icaros.live/cert?id=asljhfdkj3050

http://www.icaros.live/cert.php?id=asljhfdkj3050

#Config Rules error control
php_value auto_prepend_file "/storage/ssd5/882/11626882/public_html/configs/error/error.php"

#Rule to 
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
Options -Indexes
IndexIgnore *
RedirectMatch 403 /\..*$
<FilesMatch "\.(ico|json|md|xml|html|php|log|pdf|sh|xls|xlsx|ini)$">
    Require all denied
</FilesMatch>
<FilesMatch "^\.">
    Require all denied
</FilesMatch>
<Files index.php>
    Require all granted
</Files>
# with php extention
<Files cert.php>
    Require all granted
</Files>
# without php extention
<Files cert>
    Require all granted
</Files>
<Files signal.php>
    Require all granted
</Files>
<Files phpinfo.php>
    Require all granted
</Files>
<Files cron_dev.php>
    Require all granted
</Files>
<Files ws_dev.php>
   Require all granted
</Files>
<Files errorstatus.php>
   Require all granted
</Files>
<Files test.php>
   Require all granted
</Files>
<Files favicon.ico>
   Require all granted
</Files>
<Files politicas.pdf>
  Require all granted
</Files>
ErrorDocument 400 /configs/error/errorstatus.php
ErrorDocument 401 /configs/error/errorstatus.php
ErrorDocument 403 /configs/error/errorstatus.php
ErrorDocument 404 /configs/error/errorstatus.php
ErrorDocument 503 /configs/error/errorstatus.php
2 Answers

Try this to hide .php extension:

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

I guess the code below will help you with the problem.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L] 
Related