In my /var/www/ directory I have a lot of sub directories, one is learning/, which is where I place all my web projects that I'm following from different PHP or CSS/HTML books, another called projects/, for actualy projects I might undertake. I currently have port forwarding set up on my router but it alwasy points to /var/www/, never to an acutal project I might be running from the projects/ directory. Any idea on how I can set my apache to pull up a specific site under projects when a particular domian is entered in the URL? Thanks.

Recommended Answers

All 3 Replies

Depends on the version of Apache but this should work in all of them. You can create a configuration file in /etc/httpd/conf for the site your trying to access when the URL is entered. Below is the configuration file I use to redirect http://<any domain on the server>/support/ to the subdirectory where I have the support application:

[root@hpsrvr conf]# more support.conf
<IfModule mod_alias.c>
Alias /support /var/www/html/support
</IfModule>
<Directory /var/www/html/support >
   Options None
   Order allow,deny
   allow from all
</Directory>

Once you have the support.conf file (or what ever you call yours) you then add a line to the bottom of the httpd.conf file that reads:

Include /etc/httpd/conf/support.conf

You can either create one master fiel to add all of yor special configurations in or create a separate file for each project.

In your config file above, what is Alias /support refering to? I see that it's pointing to /var/www/html/support but where does Alias support actually come into play?

Like I said in the posting it would be added after the domain name
http://<any domain on the server>/support
Basically it says if you receive a domain name with /support after the name then redirect it here...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.