Forum Moderators: phranque
I have several pages with varying query string values in them.
I am trying to integrate all of those query strings into one rewriterule to redirect all of them to the root.
This is what I have in the htaccess
RewriteCond %{QUERY_STRING} ^ArticleID= [OR]
RewriteCond %{QUERY_STRING} ^DepartmentID= [OR]
RewriteCond %{QUERY_STRING} ^Newsid= [OR]
RewriteCond %{QUERY_STRING} ^NewsID= [OR]
RewriteCond %{QUERY_STRING} ^article=
RewriteRule \.asp$ http://www.example.com/? [R=301, L]
However, this is resulting in a 500 Internal Server error [without the OR directive as well]
Please advise if there's any way to do this or if I need to have separate rules for each of those query strings.
Thanks a lot!
I have quite a few other rewriterules as well primarily for security purposes.
#MANY RFI ATTEMPTS USE THE WWW PERL LIBRARY FOR THE SCRIPT AND THIS ATTEMPTS TO BLOCK THEM
RewriteCond %{HTTP_USER_AGENT} libwww-perl [NC]
RewriteRule ^.*$ - [F]#PREVENT HTTP QUERY STRING
RewriteCond %{QUERY_STRING} ^.*=(ht¦f)tp\://.*$ [NC]
RewriteRule .* - [F,L]#BLOCK ACCESS TO WP-INCLUDES
RewriteRule ^(wp-includes)\/.*$ ./ [NC,R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Please let me know what other information you need from me to sort this out.
Thanks again as usual :)
Please address my second question above. Thanks.
This is all I can get Jim
[02/Nov/2009:12:03:21 -0600] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 GTB5 (.NET CLR 3.5.30729)"[02/Nov/2009:12:03:21 -0600] "GET /favicon.ico HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 GTB5 (.NET CLR 3.5.30729)"
[02/Nov/2009:12:03:24 -0600] "GET /favicon.ico HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 GTB5 (.NET CLR 3.5.30729)"
Hope this helps!
Thanks
You may or may not see anything wrong when viewing/editing the file, but perhaps the incorrect characters will get re-encoded to something that will show in your error log.
Do be sure in the future to only edit server config files with a plain-text editor.
[added] I just copied and pasted the new rule you posted in your first post above, just in case I might spot an encoded character. I noticed that there is a space between "[R=301," and "L]" in that rule that is not at all obvious when viewed in this forum's font. That space could also be the problem.
Be aware that your are not free to 'format' server config code in any way you like; It should be formatted exactly as specified in the documentation. High-level programming and scripting languages are very forgiving of formatting variations, but Apache modules are not: They are purpose-built and written to be super-efficient and fast; if you make even the smallest mistake, Apache won't forgive it. [/added]
Jim
That extra character between the ["R=301," and "L]" caused the error.
I have removed that space and the redirects are working fine.
Thanks a ton for your help, as always Jim :)
BTW, is the code I pasted for integrating multiple RewriteCond for Query Strings correct?
Thanks again!
RewriteCond %{QUERY_STRING} ^(ArticleID¦DepartmentID¦News(id¦ID)¦article)=
Jim