How do I hide directories in Apache, specifically source-control?

前端 未结 7 1086
终归单人心
终归单人心 2020-12-02 13:40

I want to keep my website/s in version control (Subversion specifically) and use svn co to update it when there are stable versions to update, but I\'m concerne

7条回答
  •  旧时难觅i
    2020-12-02 14:11

    This can be achieved server-wide (recommended), on a single virtual-host basis, or even inside .htaccess files if your server is somewhat permissive with what is allowed in them. The specific configuration you need is:

    RewriteEngine On
    RewriteRule /\.svn /some-non-existant-404-causing-page
    
    
        IndexIgnore .svn
    
    

    The first section requires mod_rewrite. It forces any requests with "/.svn" in them (ie. any request for the directory, or anything inside the directory) to be internally redirected to a non-existant page on your website. This is completely transparent to the end-user and undetectable. It also forces a 404 error, as if your .svn folders just disappeared.

    The second section is purely cosmetic, and will hide the .svn folders from the autoindex module if it is activated. This is a good idea too, just to keep curious souls from getting any ideas.

提交回复
热议问题