[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [SOLVED] Re: Apache Redirect Question

Le 06/11/2012 16:18, craig@gtek.biz a écrit :
>> did you link the sites in sites-available to sites-enabled?
>> Wolf Halton
>> http://sourcefreedom.com
>>>> in domain1.com vhost config:
>>>> redirect permanent / http://www.domain1.com/
>>>> source:
>>>>       http://httpd.apache.org/docs/2.2/en/mod/mod_alias.html#redirect
> Good morning Mouss and Wolf,
> I have managed to accomplish my goal, and it was with help from both of
> you. Mouss, your tip is almost correct if I make two changes, and Wolf,
> your question started this line of thought for me.
> I copied my existing sites-available/domain1.com to
> sites-available/www.domain1.com, ran a2ensite www.domain1.com, then modified
> sites-available/domain1.com. It points the DocumentRoot to /var/www, same as
> sites-available/default. There is no index.html in that directory. I then
> added:
>    RedirectMatch "/(.*)" "http://www.domain1.com/$1";
> What this does is take any request for domain1.com, with any additional
> paths, and redirects the request to http://www.domain1.com, with any
> additional paths from the first request appended to the URL (I think that's
> the correct terminology).

yes, $1 replaces (.*). but in this case, you really don't need regular
expressions. you should be able to use the rule I sent you (it's
equivalent, well in theory at least!).

> [snip]
> Common sense dictates that I rename my /var/www directories to
> /var/www/htdocs/www.domainX.com, and sites-available/domain2.com to
> sites-available/www.domain2.com so I can maintain the name to site mapping
> in my mind.

I personally prefer things like sites-avaiable/www.domain2.com.conf
(with a .conf or whatever suffix) for two reasons:
- a file name ending in a .com is a bit disturbing ('ls' will show it as
a special fil...; you can't send it via email without renaming it, ...
- I don't like the "include *". if you happen to add a file in the
directory (or if you editor creates backup files in the current dir),
then these end up being included.

> [snip]

Reply to: