I just switched to a new server running 2.4.7 from 2.2.x and now i'm having a few issues. I resolved most of them that I ran across so far except this permanent redirect issue. Here is the code:
<VirtualHost *:80>
ServerName example.com
ErrorLog /var/log/apache2/example.com.error.log
CustomLog /var/log/apache2/example.com.custom.log common
Redirect 301 / http://www.example.com/
# RedirectMatch permanent /(.*) http://www.example.com/$1
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.example.com
# ServerAlias example.com
DocumentRoot /home/www/example
ErrorLog /var/log/apache2/www.example.com.error.log
CustomLog /var/log/apache2/www.example.com.custom.log common
DirectoryIndex index.jsp index.html
<IfModule jk_module>
JkMount /*.cfm worker1
JkMount /*.cfc worker1
JkMount /*.do worker1
JkMount /*.jsp worker1
JkMount /*.cfchart worker1
JkMount /*.cfm/* worker1
JkMount /*.cfml/* worker1
#JkMount /railo-context/* worker1
JkLogFile /var/log/apache2/mod_jk.log
</IfModule>
<Directory /home/www/example/>
Require all granted
</Directory>
</VirtualHost>
When I visit http://example.com, it's showing the default apache page for the /var/www/html site rather than performing the redirect. I have 2 servers running 2.4.7 and they both behave the same way, the old servers were running this code fine. I tried to use RedirectMatch which you is commented out since that did not work either. I also commented out the first vhost that was redirecting to the www vhost and added an alias to it just to get it working until i make time for it in the future to figure it out, but the ServerAlias did not render the site, it rendered the default html/index.html page.
I am puzzled and don't know where to begin. Countless hours of Googling and search the forum and there is not a single solution that I ran across. Maybe someone else has experienced this and solved, if so please let me know what the solution is.
BTW, I am looking for a non "rewrite" solution, i prefer the permanent redirect instead.
The temporary work around was to remove the default apache vhost. This is a temporary fix and will be an issue once another vhost is added to apache since one of the vhosts will have to be the "default".