dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: subdomain .htaccess

  1. #1
    Join Date
    Mar 2011
    Posts
    12

    subdomain .htaccess

    Good morning,

    I'm trying that one subdomain in my VPS can be only accessed if the request comes from my domain or IP. What is the best way to do it?

    I've found this .htaccess code in the web:

    Code:
    # deny all except those indicated here
    <Limit GET POST PUT>
    	Order deny,allow
    	Deny from all
    	Allow from xx.xx.xx.xx
    	Allow from domain\.com
    </Limit>
    Is this the best aproach?

    I've tryed:

    Code:
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_REFERER} !^http://www\.domain\.com/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://domain\.com/ [NC]
    RewriteRule ^.*$ http://www.domain.com/not_allowed_here.html [R=301,L]
    but even with requests from my domain, I'm sent to not_allowed_here.html with error.

    I could really need some help here.

    Kind regards.

    JKepler

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,429
    What happens when your IP address changes?

    If you have a restricted area, then your only answer is to protect it by a login that then grants you access if your credentials are correct.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Jan 2017
    Location
    Coimbatore, India
    Posts
    106
    As you mentioned, using allow, deny is the best method. Did this "Allow from xx.xx.xx.xx" work for you?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center