Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    37

    apache2 alias wildcard

    Hi all, I have a php application that needs rewritting to be scalable, in the mean time I'm looking for a quick way to consolidate the deployments to one folder.

    Currently each deployment has its own folder, meaning if I need to update anything it has to be copied in lots of places.
    What I'm going to do is make a quick change so the config file is loaded depending on the URL.

    So www.xyz.com/app/cus1 Would load customer 1's config
    So www.xyz.com/app/cus2 Would load customer 2's config
    ....
    I could do this by using an Alias:
    Alias /app/cus1 "/www/the_apps_files"
    Alias /app/cus2 "/www/the_apps_files"
    ....
    But that is a pain and requires a server restart when a new customer is added.

    What I'd like to do is something like
    AliasMatch ^/app/(.*)/ "/www/the_apps_files"

    This however falls over, can anyone please point me in the right direction? I've tried variations on the above but none seem to be right.

    Thanks, Rob.

  2. #2
    Join Date
    May 2001
    Location
    HK
    Posts
    3,076

    *

    What is wrong with AliasMatch? This should work

    AliasMatch ^/app/[^/]+/*$ /www/the_apps_files


    Since /app/ANYTHING or /app/ANYTHING//// goes to the same path /www/the_apps_files, I assume the above directive would be okay?

    If not, have you ever thought of using a symlink? I prefer AliasMatch rather than symlink in this case.
    Last edited by YUPAPA; 02-18-2011 at 10:40 AM.

  3. #3
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    37
    Thanks, but that gives me 404's.

    I'm pretty sure I'm just wrong on the syntax, any further ideas?

    Not really keen of the symlinks, it's another configuration I need to remember to do.

  4. #4
    Join Date
    May 2001
    Location
    HK
    Posts
    3,076

    *

    I think I get what you want now.

    Try this:
    Code:
    AliasMatch      ^/app/([^/]+)/*$        /www/the_apps_files/$1

  5. #5
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    37
    Thanks but still getting problems:

    /app/cus1/ gets the dir listing
    /app/cus1/page.php gets 404ed

    Cheers, Rob.

  6. #6
    Join Date
    May 2001
    Location
    HK
    Posts
    3,076

    *

    If you have to get sub directories to work

    Example:
    http://www.xyz.com/app/some/dir -> /www/the_apps_files/some/dir

    The above would not work, the one below should do:

    Code:
    AliasMatch      ^/app/(.*)        /www/the_apps_files/$1

  7. #7
    Join Date
    May 2001
    Location
    HK
    Posts
    3,076

    *

    Quote Originally Posted by robjohnston View Post
    Thanks but still getting problems:

    /app/cus1/ gets the dir listing
    /app/cus1/page.php gets 404ed

    Cheers, Rob.
    Yes, my first regexpr was being quite sensitive. I thought you just had to map /app/cus1 to /www/the_apps_files/cus1

    Didn't know you need to map /app/cus1/script.php to /www/the_apps_files/cus1/script.php

    My second regexpr above should do the job

  8. #8
    Join Date
    Sep 2001
    Location
    London, UK
    Posts
    37
    Can't seem to get this to work as well as just using several Alias /app/cus1 "/www/the_apps_files"

    have tried several things and it's now taking me more time to get it right than it would for me just to create the aliases

    Thanks for your help, Rob.

Similar Threads

  1. Win 2k3/ Apache2.2 - DNS Wildcard?
    By bloodsport in forum Hosting Security and Technology
    Replies: 4
    Last Post: 03-19-2007, 02:36 AM
  2. Replies: 4
    Last Post: 04-25-2006, 12:44 AM
  3. cPanel and wildcard server alias setting
    By haalaaluu in forum Hosting Software and Control Panels
    Replies: 2
    Last Post: 11-25-2005, 02:47 PM
  4. Apache2 Help
    By jprice in forum Hosting Security and Technology
    Replies: 6
    Last Post: 01-31-2005, 07:44 PM

Posting Permissions

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