Apache 2.4.x Better than rewriting

With httpd Apache 2.4.x is is more simple to do stuff than with 2.2.x

Like forcing the www. in front of a domain. Apache now supports the If Elseif Else :-) Pretty nice!
Light example

<If "$req{Host} != 'www.example.com'">
    RedirectMatch (.*) http://www.example.com$1

Easy, isn’t it?

A bit more old fashion way, so you can use the %{bla} stuff you already know.

<If "%{HTTP_HOST} == 'example.com'">
Redirect permanent / http://www.example.com

Also nice is the Define Directive.

OK you have to start apache with the -D parameter. Like httpd -D TEST

<IfDefine TEST>
Define servername test.example.com
<IfDefine !TEST>
Define servername www.example.com
Define SSL

If you have some example, please let me know!

Leave a Reply

Your email address will not be published. Required fields are marked *