Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 169341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:36:49+00:00 2026-05-11T12:36:49+00:00

I have an issue with serving a large amount of VirtualHosts and I was

  • 0

I have an issue with serving a large amount of VirtualHosts and I was wondering if there is a more efficient way of doing things.

I’m currently using the Location directive to serve a large amount projects from different departments, over 300 projects from 19 departments in total. The structures is the same for every Location directive except for the directories the files are served from. What I currently have is a large file that looks something like this:

<VirtualHost *>     ServerName www.myserver.com      <Location /departmentA/project1>        AuthType Basic        AuthName 'By Invitation Only'        AuthUserFile /usr/local/departmentA/project1/passwords        Require valid-user     </Location>      <Location /departmentA/project2>        AuthType Basic        AuthName 'By Invitation Only'        AuthUserFile /usr/local/departmentA/project2/passwords        Require valid-user     </Location>      <Location /departmentB/project1>        AuthType Basic        AuthName 'By Invitation Only'        AuthUserFile /usr/local/departmentA/project1/passwords        Require valid-user     </Location>  </VirtualHost> 

As you can see all these structures are the same except for the paths. What I would like is of course something where I can use variables for the department and project names and just maintain a single Location directive. I assume that this is also less heavy on the server and memory.

<VirtualHost *>     ServerName www.myserver.com      <Location /$1/$2>        AuthType Basic        AuthName 'By Invitation Only'        AuthUserFile /usr/local/$1/$2/passwords        Require valid-user     </Location>  </VirtualHost> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:36:50+00:00Added an answer on May 11, 2026 at 12:36 pm

    I don’t know of any way to do that specifically, as I don’t think AuthUserFile accepts a dynamic argument. It might be easiest to write a little script in your language of choice that takes a template for the <Location> block and repeats it for each directory you want to protect. Example, in Python:

    #!/usr/bin/python import sys print '<VirtualHost *:80>' print '   ServerName www.myserver.com' for path in sys.stdin:     print '   <Location /%s>' % path.strip()     print '      AuthType Basic'     print '      AuthName 'By Invitation Only''     print '      AuthUserFile /usr/local/%s/passwords' % path.strip()     print '      Require valid-user'     print '   </Location>' print '</VirtualHost>' 

    For each line of the form ‘departmentA/project1’ it reads on standard input, it prints out the corresponding <Location> section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Not really - you can use SELECT to initialize a… May 11, 2026 at 1:58 pm
  • added an answer It is possible and simple. In your Feature.xml file, simply… May 11, 2026 at 1:58 pm
  • added an answer Are you saving this file as UTF8? Check your editor… May 11, 2026 at 1:58 pm

Related Questions

I have an issue with using AWK to simply remove a field from a
Like every other web developer on the planet, I have an issue with users
I have run into an issue with WPF and Commands that are bound to
I have a really odd issue with an ItemRenderer. I have a main.mxml container
I have an application deployed into multiple zones and there are some issues with
We have recently migrated a large, high demand web application to Tomcat 5.5 from
I have a simple question and wish to hear others' experiences regarding which is
I'm writing a reasonably complex web application. The Python backend runs an algorithm whose
Here is the problem: we have lots of Javascripts and lots of CSS files,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.