Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've two applications in my webroot,

/var/www/mysite
/var/www/blog

I want to access mysite application as http://mysite.com and similarly blog applications as http://mysite.com/blog . I'm trying this setup locally so,I've updated hosts file as with following line.

  127.0.0.1 mysite.com www.mysite.com    
  127.0.0.1 mysite.com/blog www.mysite.com/blog # May be looks somewhat foolish with this line

I've created a virtual host for mysite application with DocumentRoot as /var/www/mysite and able to access this, but I'm unable to understand whether I need to create separate virtual host for blog application or I need to modify existing mysite virtual host file ?

Following is mysite application virtual host file,

<VirtualHost *:80>
      ServerAdmin webmaster@localhost
      ServerName www.mysite.com
      ServerAlias myssite.com

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]

    DocumentRoot /var/www/mysite
    <Directory />
       Options None
       Order deny,allow
       allow from all
    </Directory>
   <Directory /var/www/mysite>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
   </Directory>

    SetEnvIf Host (.*) custom_host=$1
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error-mysite.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access-mysite.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory> 
</VirtualHost>
share|improve this question

closed as off-topic by Iain, Jenny D, mdpc, Dennis Kaarsemaker, Falcon Momot Jul 17 '13 at 1:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about hardware or software used in a home setting are off-topic because they require answers that may not be practical for the business and support professionals here. You should try asking on Super User instead." – Iain, Jenny D, mdpc, Dennis Kaarsemaker
If this question can be reworded to fit the rules in the help center, please edit the question.

    
I even don't know is it possible or not,if anything is wrong please guide me. –  Mahesh.D Jul 16 '13 at 10:14
1  
You are overcomplicating things severely. Start by reading httpd.apache.org/docs/2.2/urlmapping.html . –  Jenny D Jul 16 '13 at 12:37
    
@JennyD: Thanks Jenny I'll go through with link which you have provided. –  Mahesh.D Jul 16 '13 at 12:41

1 Answer 1

up vote 1 down vote accepted

You don't need separate virt host for the blog, imho. All you need is to use alias

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.mysite.com
    ServerAlias myssite.com

    DocumentRoot /var/www/mysite
    Alias /blog /var/www/blog

   <Directory /var/www/mysite>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
   </Directory>

   <Directory /var/www/blog>
      ...
   </Directory>
</VirtualHost>
share|improve this answer
    
Thanks for your response but its not working –  Mahesh.D Jul 16 '13 at 10:32
    
What do you mean by "Is not working" ? What in /var/log/httpd/access.log and /var/log/httpd/error.log –  ALex_hha Jul 16 '13 at 10:43
    
I've given alias and a directory block for blog app though its not working how I desired. –  Mahesh.D Jul 16 '13 at 10:48
    
And forgot to mention that I'm configuring vhost using sites-available config file by issuing a2ensite mysite cmd. –  Mahesh.D Jul 16 '13 at 10:51
    
Could you create a simple php file with phphinfo(), call it i.php and put in /var/www/blog. Then open it in any browser myssite.com/blog/i.php Will it work? –  ALex_hha Jul 16 '13 at 11:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.