0

When I hit url on my browser with .htaccess I can see the code of htaccess. It should be Access forbidden! or not accessible. How can I give restriction to htaccess as no one can access it.

domainname/.htaccess it's shown me code of htaccess.

Options +FollowSymLinks
RewriteEngine on

# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

php_value memory_limit 256M enter image description here

Dilip Hirapara
  • 14,810
  • 3
  • 27
  • 49
Barun
  • 11
  • 4

2 Answers2

0

Htaccess RedirectMatch can be used to hide/protect certain file extensions:

Options +FollowSymLinks
RewriteEngine on

RedirectMatch 403 \.(htaccess|htpasswd|ini|log|sh|inc|bak|bkp|sql)$

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

result:

example.com/.htaccess -> 403
example.com/test -> 200 index.php
example.com/test.php -> 200 index.php

Read about at the following question: How to hide certain file type using apache .htaccess?

MaartenDev
  • 5,631
  • 5
  • 21
  • 33
0

check your apache.config file.

<Files ".ht*">
Require all denied
</Files>

Add this code. It will restrict accessing .htaccess file

Samir Patel
  • 167
  • 1
  • 7