apache - .htaccess deny php files from all except index -
i have .htaccess file following contents:
<ifmodule mod_rewrite.c> rewriteengine on setenv http_mod_rewrite on rewritebase /wsproject/ options -indexes directoryindex index.php rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l rewriterule ^(.+)$ index.php?url=$1 [qsa,l] </ifmodule>
i want hide users: directory structure , private files, while enable public files: *.js, *.html, *.css, *.swf, *.jpg , other stuff. want .php files accessible file system, except index.php in root dir.
i want serve request via http written (abstract) mvc url pattern like: www.domain.com/lang/controller_name/action_name/arg1/arg2/././argn
, being rewritten .htaccess, , public *.html, *.js ...etc files.
while options -indexes
hides file listing, not prevent undesirable request e.g.: www.domain.com/library/bootstrap.php
being served. whereas deleting/commenting out rewritecond %{request_filename} !-f
solve this, in case none of public .html, .css, .js ...etc files served.
i tried apply deny each php files except index.php 500-internal server error message. im doing on localhost, on windows.
any ideas?
instead of stating existing files should directed index.php, can except *.js, *.html, *.css, *.swf, *.jpg should directed index.php.
this isn't same denying, since don't give forbidden response. though in case don't give out information files exist or not, i'd argue it's better solution.
<ifmodule mod_rewrite.c> rewriteengine on setenv http_mod_rewrite on rewritebase /wsproject/ options -indexes directoryindex index.php rewriterule \.(js|html|css|swf|jpg)(\?|$) - [qsa,l] rewriterule ^index.php(\?|$) - [qsa,l] rewriterule ^(.+)$ index.php?url=$1 [qsa,l] </ifmodule>
note rewriting -
, means no rewriting done @ all.
Comments
Post a Comment