Re: Apache (was Apace) Redirect Question
On Sat, Nov 3, 2012 at 8:31 AM, <email@example.com> wrote:
> On Friday, November 2, 2012 21:48, "Wolf Halton" <firstname.lastname@example.org> said:
>> Make these changes in sites-available files. That is what those files in
>> there are for.
>> I don't have the specific directive but I can put up one of my servers'
>> apache files for you.
>> Wolf Halton
>> Apache developer:
> Thanks Wolf, and it makes sense that the directives that apply to a site would
> go in that site's definition. I just don't quite understand what I need to put
> in there. When I check the default site access logs, I see the request for
> http://domain1.com come in as /, but I also see the same for domain2.com and
> for the IP address. All three show up as "GET / HTTP/1.1" I understand that the
> server does not know about the sites by those names because I haven't
> configured it to do so.
> Obviously Apache is capable of this distinction because if I change the
> ServerName in domain1's sites-available to domain1.com then the index.html file
> in /var/www/htdocs/domain1.com is returned to the client. If I add the
> ServerAlias www.domain1.com directive then both the request for domain1.com and
> the request for www.domain1.com return /var/www/htdocs/domain1.com/index.html,
> but the URL does not change in the navigation bar, and both show up in the log
> as "GET / HTTP/1.1".
> I know I've entered URL's into my browser's navigation bar and watched them
> change to something else, such as entering http://example.com and being
> redirected to http://www.example.com, with that URL then populating the
> navigation bar. So I'm close in that both requests return the file that I
> want returned, but I don't know how to have the URL change so the user sees
> the URL I want them to see.
> So I guess what I'm asking is, how do I configure things so that the server
> knows a request for domain1.com should be handled as if it were a request for
> www.domain1.com, and sends the client to that URL?
> Sent - Gtek Web Mail
Here are the settings for one of my multisite servers.
I am using Apache2.2 on Debian Squeeze with the backports repo enabled
- thus it is not a stock Squeeze install
This is even simpler than I thought I would be giving you as the
NameVirtualHost directive is in conf.d/virtual.conf
If you notice, the apache2.conf file has only the generic server info
and all of the specific user configs are in other places.
It handles the "did they type www. or not in the virtual config as a
server alias. This is not a redirect, which would add details to the
url, like you get when you type http://evergreen.lyrasistechnology.org
into the address bar, because these 2 directories are simply not
The evergreen address is pointed at a directory outside of /var/www
and can be shared by multiple clients and the search scope is
different in each.
** You may get a warning when you restart apache with this setup
because default-ssl is listening on port 443 - the complaint will be
that apache does not like mixing virtual servers with port numbers and
others without. I haven't had to restart this setup for months, so I
don't remember the exact warning message.
#=======snippet from apache2.conf
# Include generic snippets of statements
#=======Contents of conf.d directory=======================
charset localized-error-pages other-vhosts-access-log security virtual.conf
#=======Configuration of virtual.conf=======================
wolf@SERVER-01:/etc/apache2/conf.d$ cat virtual.conf
# running virtual hosts
#======Contents of the sites-available directory============
default default-ssl legacy
#======Configuration for dev.example.net====================
wolf@SERVER-01:/etc/apache2/sites-available$ cat default
Options Indexes FollowSymLinks MultiViews
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Allow from all
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
Options Indexes MultiViews FollowSymLinks
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
#========Configuration for legacy.example.net======================
wolf@SERVER-01:/etc/apache2/sites-available$ cat legacy
# This is the settings file for the legacy.example.net site
# Indexes + Directory Root.
# CGI Directory
ScriptAlias /cgi-bin/ /var/www/legacy/cgi-bin/
CustomLog /var/www/legacy/logs/access.log combined
This Apt Has Super Cow Powers - http://sourcefreedom.com
Open-Source Software in Libraries - http://FOSS4Lib.org
Advancing Libraries Together - http://LYRASIS.org
Apache Open Office Developer email@example.com