Monday, February 21, 2011

How can I use a wildcard in my .htaccess but only for 1 subdomain?

I add to httpd.conf:

ServerAlias *.domain.com

Now I want only 1 subdomain: h.domain.com to load hobbies.php

Which lines do I need to add into my .htaccess file to make this happen?

From stackoverflow
  • This should work, but I can't test it at the moment. Give it a shot.

    SetEnvIfNoCase Referer "^http://h.domain.com" allow_hobbies=1
    
    <FilesMatch "hobbies.php">
      Order Deny, Allow
      Allow from env=allow_hobbies 
    </FilesMatch>
    

    Note: You should probably not rely on this for security purposes, as there are ways around it (rather simple ones at that). The Referer header can be faked.

0 comments:

Post a Comment