.htaccess - mod_rewrite deny acces if parameter equals something -



.htaccess - mod_rewrite deny acces if parameter equals something -

i have urls like mydomain.com?act=somethingbad mydomain.com?act=somethingworse and mydomain.com?act=somethinggood mydomain.com?act=somethingbetter

i need create bad actions forbidden. tried like:

rewritecond %{query_string} act=(.*) rewritecond %{query_string} act=[^(somethinggood)] rewriterule ^(.*) - [f]

because have more bad actions want exclude de actions rule. above illustration doesn't work.

any ideas?

use these rules:

rewritecond %{query_string} (^|&)act=(.*) rewritecond %{query_string} !(^|&)act=(somethinggood|somethingbetter)(&|$) rewriterule ^(.*) - [f]

parameter act can (e.g. http://example.com/?act=somethinggood , http://example.com/?mode=happy&act=somethinggood , http://example.com/?mode=happy&act=somethinggood&extra=yes ok)

if have empty value act parameter, rejected (e.g. http://example.com/?act= treated bad parameter)

based on url examples have provided, rule applied urls have act parameter in query string.

.htaccess mod-rewrite

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -