Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Can anyone tell me how to configure apache to not display a website folder name at the end of a base URL, please? - but only for one out of many websites.

Let me describe the scenario ...

I have a test server with a number of websites in separate folders inside /var/www. Because it a test server, I am accessing it via it's IP address (64.244.144.78). So I would access a website via 64.244.144.78/a_website_folder

The trouble began when I needed one of the sites, which is called applications, to have a sub-domain name of applications.ourorganisation.org instead of using the IP Address format as above.

The sub-domain was created by our IT guy on our currently existing Windows server. He then pointed the sub-domain at my Linux test server's IP address of 64.244.144.78 (apparently he could not add the subdirectory information leading to the applications website).

To counter this problem, I created an index.php file in 64.244.144.78/var/www and used PHP code to redirect to the applications website folder.

All that worked but I now when I visit applications.ourorganisation.org, I am redirected to applications.ourcompany.org/applications.

It not a disaster but I would like to NOT have the applications directory name at the end.

share|improve this question
    
Why aren't you using named virtual hosts in apache? –  Deepak Mittal Apr 12 '12 at 10:41

1 Answer 1

What you need is VirtualHost definition.

In you /etc/httpd/conf.d (Fedora) create a new file and call it application.ourorganisation.org.conf.

In this file try this format:

<VirtualHost *:80>
    ServerName application.ourorganisation.org
    ServerAdmin admin@ourorganisation.org
    DocumentRoot /var/www/a_website_folder/

    <Location />
        Options +Indexes +FollowSymLinks
    </Location>

</VirtualHost>

Then restart httpd:

service httpd restart

If you want other hostname to be also forwarded to the same config, Try this under the ServerName Directive

ServerAlias app.ourorganisation.org application.localhost
share|improve this answer
    
Thanks for your response. I have virtualhosts defined on my server under /etc/httpd/conf/vhosts.The only problem is they don't have any effect. When I build sites on my Ubuntu VPS, I always have to define a virtualhost file for each site, enable it and restart apache for the site to be visible and work. BUT, on my employers CENTOS server, I noticed, totally be accident, once I drop my wedsite files into /var/www, it immediately becomes visible in a browser. I described this issue @ unix.stackexchange.com/questions/35319/… –  sisko Apr 12 '12 at 14:46
    
Oh you can change the default httpd.conf DocumentRoot to be something like var/www/goaway/ which bypass your application folder. Might not be the most elegant solution but it should work –  whoami Apr 12 '12 at 15:20
    
yep! I already changed DocumentRoot but remember I have multiple websites on the server. I can only make this URL renaming work for one site. HOWEVER, I do think finding a way to make my virtualhost definitions to work will solve this problem ... –  sisko Apr 12 '12 at 16:06
    
Im not sure what you are after, but you can create multiple virtual hosts directive for multiple site. –  whoami Apr 12 '12 at 22:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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