SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Can this be done? (IP dependant directories from same URL)

    I'm hosted on Unix and have the following folders:
    /home/me/dev (development site)
    /home/me/live (final live site)

    vhosts is pointing to the mydomain.com directory and I have a symbolic link pointing to the required folder:
    ln -s /home/me/dev mydomain.com

    This allows me to run tests in /dev without messing with the live site files. When happy I push my changes over to /live. If I want to check /live I just change the symbolic link to /live.

    Of course I can only point a symbolic link to one directory at a time.

    After launch, I will need to be pointing to /home/me/live/ but would still like to develop in the /dev folder when necessary.

    Question:
    Is it possible to configure Apache or Unix so, when visiting mydomain.com, it will read my ip address and serve me /home/me/dev/ whilst the rest of the world are served /home/me/live ?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Why not use dev.mydomain.tld and have it point to the dev location while everything else concerning mydomain.tld points to the live section? (You do not want your IP going to the dev instead of the live, like you asked for. How would you review the live site if a problem is reported?)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are a few reasons for not wanting to use a subdomain. I have other setups where i am doing just that but in this instance I would need to set it up as described.

    If a problem was reported on the live site I would simply take away the IP condition and access it like everyone else.

    It might be best to re-define my request to determine whether there is ANY way to use ANY conditional statement to point to separate directories? If that is possible I can move on to look into how I might pass that condition my ip address.

    Anyone have any ideas?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    So you just want to create an over complication...for no real reason? o.O
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh dear. So by saying there are a few reasons and not specifying them, you assume that they aren't real and then go on to patronise by calling this 'wanting to be overcomplicated'?

    I am simply asking for any HELPFUL advice from anyone that has a better understanding of apache and vhosts without going into details of WHY as that would bloat this thread and move away from being a discussion about HOW.

    If specifying reasons is the only way to get advice on the matter I will specify one to give proof that they are valid and say that there are others equally important.

    Reason One of Many:
    I have an SSL certificate on the site that would not work with a subdomain as it is not a wildcard certificate. I can not overcome this with a self-signed certificate as a device that will use it does not work with self-signed certificates.

    So, getting back to the question, can someone please provide any info on HOW this might be done. A more helpful response than the last one would be a simple 'CAN or CANT because'.

    Thanks

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    No, it is not possible, which is why I am "patronise" because it is not possible.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    haris,

    You can use mod_rewrite to examine Apache's {REMOTE_ADDR} variable and make a redirection based on that.

    I'm sure that there must be something else in your question, though, that I'm not sure can be accounted for with mod_rewrite's redirection although I can't imagine what it might be. Just pop the mod_rewrite code into your .htaccess file in the DocumentRoot (of the domain) and that should be it. Try:

    Code:
    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} ^123\.123\.123\.123$ # Your IP address - I hope you have a fixed IP address
    RewriteRule .? dev%{REQUEST_URI} [L]
    NOTA BENE: This will fall over if live is the DocumentRoot because dev is outside your webspace - move dev under live and alter the RewriteRule regex to !^dev/.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

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