Solved

Is Conditional Aliasing possible?

Posted on 2006-06-08
8
249 Views
Last Modified: 2010-03-04
I'm using Apache 2.2
I've created 2 Virtual sub hosts.

I want one to be used for my live www and the other for internal testing, so I call it test.

DocumentRoot for www =  /usr/local/apache/htdocs/www
DocumentRoot for the test site = /usr/local/apache/htdocs/test

Ideally I'd like to have the test site identical to the live site except for files I add to it or change.

If under the test site, for example, I use     Alias /images/ /usr/local/apache/htdocs/www/images/

then when I access http://testsite/images/ all my live site images come up fine. But now what I want to do is create a system where is I put an actual directory under test ...ie  /usr/local/apache/htdocs/test/images ... I want files in that directory to be used if they're present. So I can change a file in the test environment and see it from that site without having to duplicate the entire site or directories.
0
Comment
Question by:dltjdt
  • 2
  • 2
  • 2
8 Comments
 
LVL 6

Expert Comment

by:philjones85
ID: 16871370
if you're using virtual hosts, you should have two separate mappings to the "/images/" folder

<VirtualHost *:80>
    ServerAdmin you@email.com
    DocumentRoot /usr/local/apache/htdocs/www
    ServerName domain.com

    <Directory "/">
        AllowOverride All
        Options FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>
    Alias /images/ "/usr/local/apache/htdocs/www/images/"
    <Directory "/usr/local/apache/htdocs/www/images">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin you@email.com
    DocumentRoot /usr/local/apache/htdocs/test
    ServerName test.domain.com

    <Directory "/">
        AllowOverride All
        Options FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>
    Alias /images/ "/usr/local/apache/htdocs/test/images/"
    <Directory "/usr/local/apache/htdocs/test/images">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 16897811

dltjdt  - are you asking that if the file exists in test, use that one, otherwise use the one that is in the live site?
0
 

Author Comment

by:dltjdt
ID: 16908503
Yes.... What Periwinkle said!
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:dltjdt
ID: 16908511
But I'm hearing that this isn't possible. Does anyone know of a method that gets close to this affect? I've already set up the subhosts and I'm currently syncing between the two, but would prefer to simply copy the files that have changed once we QC that only those file exist on the test site.
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16908517
why not make the "live site" icons folder a link to the "test site" icons folder?
0
 
LVL 15

Accepted Solution

by:
periwinkle earned 125 total points
ID: 16910780
Actually, I believe that you CAN do this via mod_rewrite;  see:

http://httpd.apache.org/docs/2.2/misc/rewriteguide.html

and look at the section entitled:

Search pages in more than one directory

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now