apache - Mod-rewrite lock execution of PHP files and access to .git folder -


i want use mod-rewrite block execution of files except bootstrap.php file in document root, , want block access files in .git folder (also in document root). (probably better solution) allow access files inside of directory called public (there multiple directories called public in different parts of application), deny direct access other file while directing other requests through bootstrap.php file. here's have.

rewriteengine on  rewritecond %{request_filename} !-f rewriterule .* /bootstrap.php  rewritecond %{request_filename} -fd rewriterule .*\.php /denied.php  rewritecond %{request_filename} -fd rewriterule \.git /denied.php 

any suggestions appreciated.

you not allowed use multiple verification on condition files, give error bad flag delimiters, if use this:

rewritecond %{request_filename} !-fd 

so this:

options +followsymlinks -multiviews rewriteengine on  # not existent file rewritecond %{request_filename} !-f # , not folder rewritecond %{request_filename} !-d # , not symbolic link rewritecond %{request_filename} !-l # , not bootstrap.php or denied.php rewritecond %{request_filename} !(bootstrap.php|denied.php)$ # redirect /bootstrap.php rewriterule .* /bootstrap.php  # existent file rewritecond %{request_filename} -f [or] # or directory rewritecond %{request_filename} -d [or] # or symbolic link rewritecond %{request_filename} -l # , not bootstrap.php or denied.php rewritecond %{request_filename} !(bootstrap.php|denied.php)$ # contains .php or .git + else redirect /denied.php rewriterule \.(php|git)/?.*$ /denied.php 

you can use f flag instead returns 403 forbidden response client browser.

rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d [or] rewritecond %{request_filename} -l rewritecond %{request_filename} !(bootstrap.php|denied.php)$ rewriterule \.(php|git)/?.*$ - [f] 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -