Forum Moderators: phranque
The original was this, which worked just fine all along.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
It pinged fine today and I could access with FTP, so I downloaded the .htaccess file and saw this:
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://example.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.example.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.example.com$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.google.com$ [NC]
RewriteRule .*\.(.*)$ http://www.example.com/$1 [R,NC]
No way! I don't believe that could happen by accident, especially with google added in there, something is too fishy.
[edited by: jdMorgan at 9:50 pm (utc) on May 25, 2007]
[edit reason] Fix resolving domain - by request [/edit]
This code will destroy your URLs, 302-redirecting requests for <anything>.<filetype> to example.com/filetype unless the referrer is one of those listed.
The code was either created by cPanel (or similar), or by someone who knows little about regular expressions and mod_rewrite. cPanel and others "write" non-optimized code like this...
Change all your passwords right away!
Jim
Jim, can you fix the exampe.com typo above, some domainer has it for type-in typos with pop-ups.
Jim
The right response to a hack is to secure the server and then stop changing things until the breach is investigated. Before replacing any files, rename them so that their original timestamps and contents can be examined. Otherwise, their forensic value is destroyed and all you can do is fix 'well-known' security problems and hope you don't get hacked again... :(
Jim
Thanks, I'll pass the info on including the filename.
I assume that the "allowed" sites listed are your own (and Google).
It has no provision to serve content if the referrer is blank or missing, so you will get blocked if you try to directly access an image etc.
It blocks anything that ends in .something. I assume that it should have only been set to block images, and so on.
This part is odd: RewriteRule .*\.(.*)$ http://www.example.com/$1 [R,NC] as it simply redirects domain.com/whatever.something to www.domain.com/something.
cPanel typically writes 'bad code' -- but it's only bad in the sense that it is un-optimized and has a 'hole' in it -- It can be by-passed by adding a valid port number to the hostname request header. In this case, the code is not only "bad," but badly-broken.
Jim