Deny Access to .git Directory and .gitignore File on Apache cPanel

Опубликовано: 19 Октябрь 2024
на канале: Become a Web Developer
396
4

Here is the conde you need to place in your Apache 2.4 (or 2.2, but note the changed syntax in the video...) on cPanel

NOTE: I could not copy the angle brackets into the video description. So,
you can follow this link:
https://www.anamericanwebdeveloper.co...

DirectoryMatch "^/.*/\.git/"
Require all denied
/DirectoryMatch

Files ~ "^\.git"
for apache 2.2 use Order allow …
for apache 2.4 use the “Require all denied” syntax
Order allow,deny
Deny from all
Require all denied

/Files


In this git and cpanel tutorial you will learn how to NOT serve your Git repository from the public html directory:
1. Use git for deployment on cpanel.
2. Prohibit public access to git repo.
3. Modify apache .conf/configuration files to match directories and files with regular expressions to stop access to a git repo.
4. Stop your web server from serving up hidden .git files.