.htaccess and sub-domains

Help with html/xhtml, css, javascript and other related topics.

Moderator: Moderators

.htaccess and sub-domains

Postby Stewie Griffin on Fri Nov 11, 2005 11:42 am

I'm preventing hot-linking from my site. Issue is, I want to prevent from both my main portfolio AND sub-domain. Here's what I wrote:

Code: Select all
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?site.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sub.site.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf)$ redirect.gif [R,L]


Now, I am capable of getting this to work for the main site (the first listed), but not for the sub.
Is there some lil' extra step I should be taking?

Thanks in advance for all your replies.
Stewie Griffin
Registered User
Registered User
 
Posts: 103
Joined: Tue Aug 02, 2005 10:20 pm
Location: King, NC

Postby Stewie Griffin on Sun Nov 13, 2005 5:43 am

If this will help any, besides the main site (site.com), the second site (sub.site.com) contains my phpBB forum. Could it not be working due to the fact that the sub site is .php based?

I've been searching high and low, only to recieve thousands of tutorials referring to only one site on one account. I have in my directory:

site.com
sub.site.com (php)
test.com
test2.com
sub.test.com (php)
>htaccess

And I wish to prevent hotlinking on the first two, somehow using the one htaccess file. If there is an alternative way to disallow hotlinking to the sub, I'm open for suggestions (if within reason of my knowledge and easibility).
Stewie Griffin
Registered User
Registered User
 
Posts: 103
Joined: Tue Aug 02, 2005 10:20 pm
Location: King, NC

Postby Stewie Griffin on Mon Nov 14, 2005 11:07 pm

Nevermind.
It appears that this will be more trouble than I thought. I've been viewing Apache's site and I am having to know alot more than what I wish to. There's also a conflict with another code in which is inputted in the file (for security reasons, I do not wish to imply what that code refers to).

Thanks for brushing this topic and giving it a look. ;)
Stewie Griffin
Registered User
Registered User
 
Posts: 103
Joined: Tue Aug 02, 2005 10:20 pm
Location: King, NC

Postby UseLess on Mon Nov 14, 2005 11:18 pm

Greetings,

I don't know how your domains are setup but mine are in 2 seperate dirs, 1 for the forum and 1 for the website, and if I wanted to prevent hot linking I would think I would have to put a .htaccess file in the root of each domain.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby Stewie Griffin on Mon Nov 14, 2005 11:43 pm

I have my directories set-up as in the second reply. I had always thought the file was placed 'outside' the folder, where you see alias, postfix, etc, files. It worked for my main site, but not for the sub. I then moved it to both of those folders (main and sub) and get errors (500 Internal). So, after reading the Apache site, I got lost and said, "screw it" and deleted the htaccess files.

There's alot of different methods online that I had tested, and they all failed me. So, I basically gave up. :D They only work for the main site (and only if placed "outside" its directory), never for the sub.
Stewie Griffin
Registered User
Registered User
 
Posts: 103
Joined: Tue Aug 02, 2005 10:20 pm
Location: King, NC

Postby UseLess on Tue Nov 15, 2005 11:33 am

Greetings,

Shouldn't line 4 in the above be;

Code: Select all
RewriteCond %{HTTP_REFERER} !^http://sub.site.com/.*$ [NC]


or something like that as surely you'll access it with;

http://sub.site.com and not http://www.sub.site.com ?

So if the '(www\.)?' is to stay there it needs to be optional... but then I know very little about apache and could be miles off.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby Stewie Griffin on Tue Nov 15, 2005 11:42 am

Sounds like a busy weekend redoing this. :D
I played with that, too. Because, with the sub domain, I have it played out that "www" SHOULD NOT BE INPUTTED in the address, even though you can still access it that way. :? Even though it's off-topic, I think I need to contact my host about that.

I'll PM you this weekend about the other code, UL. I think that is the one giving me the 500 error, not being compatible with either my hosts settings or with the above code.

**edit**
Duhhhh
Per UL signature:
No support, scripting help via PM.
I do not provide any install services for phpBB, Mods or Styles.

:roll: I gotta pay more attention early in the morning.
Stewie Griffin
Registered User
Registered User
 
Posts: 103
Joined: Tue Aug 02, 2005 10:20 pm
Location: King, NC


Return to (X)HTML Coding

Who is online

Users browsing this forum: No registered users and 2 guests

cron