super70s
2016-07-02 03:08:57 UTC
To make a long story short I have added some Rewrite commands to my
.htaccess file to help prevent another hack of my site, which happened a
few weeks ago.
I'm just wondering if it matters if I group all the RewriteRule's
together and Rewrite Cond's together, or does it particularly matter?
Currently the file looks something like this. The first four are from
the original file, and the others are the ones I just added:
RewriteEngine on
RewriteRule ^category(.*).html$ index.php?page=category&category_id=$1
[L]
RewriteRule ^article(.*).html$ index.php?page=article&article_id=$1 [L]
RewriteRule ^page_(.*).html$ index.php?pagedb=$1 [L]
RewriteRule ^index.html$ index.php
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
Would it be best to move that Rewrite Rule at the very end (which was
one of the hack prevention commands I found online, along with all those
Rewrite Cond's) up with the other four original Rewrite Rules at the top?
Or group all the RewriteCond's at the top, before all the RewriteRule's?
It seems this is the way it's done in all the examples I looked at.
.htaccess file to help prevent another hack of my site, which happened a
few weeks ago.
I'm just wondering if it matters if I group all the RewriteRule's
together and Rewrite Cond's together, or does it particularly matter?
Currently the file looks something like this. The first four are from
the original file, and the others are the ones I just added:
RewriteEngine on
RewriteRule ^category(.*).html$ index.php?page=category&category_id=$1
[L]
RewriteRule ^article(.*).html$ index.php?page=article&article_id=$1 [L]
RewriteRule ^page_(.*).html$ index.php?pagedb=$1 [L]
RewriteRule ^index.html$ index.php
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
Would it be best to move that Rewrite Rule at the very end (which was
one of the hack prevention commands I found online, along with all those
Rewrite Cond's) up with the other four original Rewrite Rules at the top?
Or group all the RewriteCond's at the top, before all the RewriteRule's?
It seems this is the way it's done in all the examples I looked at.