jeffschips

Well-Known Member
Jun 5, 2016
221
23
68
new york
cPanel Access Level
Root Administrator
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?

Code:
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]
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,027
313
cPanel Access Level
Root Administrator
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.

Code:
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.
 

jeffschips

Well-Known Member
Jun 5, 2016
221
23
68
new york
cPanel Access Level
Root Administrator
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?
 

jeffschips

Well-Known Member
Jun 5, 2016
221
23
68
new york
cPanel Access Level
Root Administrator
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?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,027
313
cPanel Access Level
Root Administrator
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.