0

Noob Here.. I have the following folder structure on my Ubuntu Machine

 /var/www/
        /folder1
        /folder2

Now i want to redirect my url xyz.com to folder1 & xyz.com/blog to folder2. I am using the following Vhost Config file

For xyz.com to folder1

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

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

And for xyz.com/blog to folder2

   <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName xyz.com/blog
    ServerAlias www.xyz.com/blog

    DocumentRoot /var/www/folder2
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

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

When i enter xyz.com in url, it serves me index file from folder1(As expected & correct) but when i enter xyz.com/blog it shows 404:Not found Error

  Not Found

  The requested URL /blog/ was not found on this server.

  Apache/2.2.22 (Ubuntu) Server at socialcosmo.com Port 80

I have spent hours on this and still unable to figure out the problem :( Any help would be greatly appreciated

Jigar Jain
  • 1,447
  • 1
  • 15
  • 38

1 Answers1

2

There's no such thing as a host (domain name) with a path in it. xyz.com/blog is not a valid ServerName.

Delete the second virtual host and add an alias directive to your first one.

Alias /blog /var/www/folder2

Dondi Michael Stroma
  • 4,668
  • 18
  • 21
  • Yes. your answer is correct. And its working fine but with one problem. When i hit xyz.com it properly serves index page of folder1, But when i hit www.xyz.com then the Browser shows an error message saying 'code'Oops! Google Chrome could not find www.socialcosmo.com'code' Any reason where i might have gone wrong ? – Jigar Jain Apr 10 '13 at 08:42
  • Also when i visit xyz.com/blog/something it shows me 404 page from xyz.com(folder1) directory – Jigar Jain Apr 10 '13 at 11:23