Lots of redirects in .htacces
Hello. Hoping everyone is having a good holiday!
I'm seeing a long, long list of entries in my .htaccess files for each domain I manage. For each of the domain's .htaccess I'm seeing entries like the following which not only includes references to *that* domain but also every other domain on the server. I can't remember what or how these got into the .htaccess file and I'm wondering:
1) given how each one references other domains on the server, if I can remove them, and
2) what is their purpose?
RewriteCond %{HTTP_REFERER} !^http://somedomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://somedomain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://somedomain.com.hostname.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://somedomain.com.hostname.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://hostname.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://hostname.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]-
Hey hey! I don't see why you couldn't remove them. Let's use your example, assuming "somedomain.com" is the domain with the .htaccess file. RewriteCond %{HTTP_REFERER} !^http://somedomain.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://somedomain.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://somedomain.com.hostname.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://somedomain.com.hostname.com$ [NC]
In this case, it's very unlikely that "somedomain.com.hostname.com" has a DNS record, so that redirect is never going to get applied. Their purpose, I really don't have any idea since it's not a domain that would normally ever exist or get traffic.0 -
The somedomain.com and somedomain.com.hostname.com are just examples of how the naming convention is used - the real names have been removed and the real names and domains DO exist on the server. So I'm wondering, given that they do exist except for how they are enumoerated here, in the example only, what do these redirects actually do? 0 -
Do those domains actually resolve though? Is there DNS setup for somedomain.hostname.com? 0 -
Yes, they all have active, working dns resolution. I.e., if you were to type somedomain.com into your browser you would be brought to somedomain.com 0 -
Right, but what about somedomain.hostname.com? Does that also exist in DNS and Apache? 0 -
When I go into WHM (not cpanel) and view the DNS zone manager and click on manage records, for each domain listed I see the records such as: somedomain.org but DO NOT see any records like somedomain.com.hostname.com which I believe is a naming convention to make cpanel play nicely with whm or something like that - never really quiet undstood that. Does that help? 0 -
Yup - that helps :D It looks like the rewrites are trying to protect images or hotlinking? Since these are all set up with the HTTP_REFERER option and the rules all reference image types, that would be my guess. But there is no cPanel-related reason you need to keep these in place. 0
Please sign in to leave a comment.
Comments
7 comments