[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

Apache Alias exclusion

Dear All

Situation :
We have a live site at a clients datacenter, we need to setup a second site for development purposes on a temporary basis.
Site is accessed through load balancer, security restrictions on the LB prevent me from setting up another hostname and creating vhosts, and I did try to setup a second site in the site.com/~user fashion.

So in short I need to setup a second site. I did try to setup the site in the following fashion

site.com/site2/

However, with this approach the following problem arises.

The two sites are identical and the vhosts file for the original site contains the following entries amongst similar entries:

    Alias   /custom/images          /site1/client/xyz/images
   Alias   /js_includes    /site1/core/js_includes

When I do access site 2 which is basically a subfolder of site1, site2 does fetch the js scripts and other include code from the folders of site1, this makes site2 unusable for development.

I need a way so that I can exclude site2 from the Alias entries of site1 or a way to force site2 to use it's own code using some server side method.

I know this might sound ridiculous, but it is a vacation emergency and I need to find a workaround untill the vacations are over.

Regards





0
http:// thevpn.guru
Asked:
http:// thevpn.guru
1 Solution
 
ravenplCommented:
Alias has no exceptions, But You can intercept aliased request with mod_rewrite, and redirect somewhere else

Into the .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#if referred from not site2
RewriteCond %{HTTP_REFERER} !site.com/site2/
RewriteRule ^custom/images/(.+) site2/temp_images/$1 [L]
RewriteCond %{HTTP_REFERER} !site.com/site2/
RewriteRule ^js_includes/(.+) site2/temp_js_includes/$1 [L]
0
 
systanCommented:
Hello

Find  filename: vhosts.conf  (inside apache folder or in subfolder[if not centos or redhat])

Add the following:

NameVirtualHost *:80   (if not included in vhosts file)

<VirtualHost *:80>
     ServerName www.YOURLOCALHOSTNAMED.X
     DocumentRoot /srv/www/htdocs CHANGE THIS IF YOU HAVE DIFFERENT FOLDER
    <Directory "/srv/www/htdocs">
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName YOURVIRTUALNAMEFOLDER.YOURLOCALHOSTNAMED.X
    DocumentRoot /srv/www/htdocs/YOURVIRTUALNAMEFOLDER
    <Directory "/srv/www/htdocs/YOURVIRTUALNAMEFOLDER">
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
>>>>>>>>>>>>>>>>>you can add another here
ServerName YOURVIRTUALNAMEFOLDER.YOURLOCALHOSTNAMED.X
    DocumentRoot  >>>>>>>>>DIFFERENT DRIVE/FOLDER IS OK
    <Directory ">>>>>>>>>DIFFERENT DRIVE/FOLDER IS OK">
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>



========================================================
You can't find vhosts in centos apache or redhat
========================================================
Try this at:(if your using centos or redhat)

/etc/httpd/conf/httpd.conf

Add the following to the last line:
--------------------------------------------------------------
NameVirtualHost *:80
<VirtualHost *:80>
     ServerName www.YOURLOCALHOSTNAMED.Xxx
     DocumentRoot /var/www/html      =centos DEFAULT FOLDER FOR www ROOT
    <Directory "/var/www/html">        =centos DEFAULT FOLDER FOR www ROOT
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName YOURVIRTUALNAMEFOLDER.YOURLOCALHOSTNAMED.Xxx
    DocumentRoot /var/www/html/YOURVIRTUALNAMEFOLDER
    <Directory "/var/www/html/YOURVIRTUALNAMEFOLDER">
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
</VirtualHost>
----------------------------------------------------------------
Restart Apache Service.

So you can type for test:
http://devarioj.localhost - [if virtualhost was setup]
OR
http://localhost/xdevarioj - [if virtualhost was NOT setup] (of-course xdevarioj is a folder inside www root).

0
 
http:// thevpn.guruAuthor Commented:
none of the answers really solved this but thanks for the input
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now