This is my first post to StackOverflow, so please bear with me......
I'm trying to redirect www.example.com to https://example.com. I've looked at quite a few solutions on StackOverflow and other forum sites, but I can't seem to get anything to work. Here are a few of the other StackOverflow pages I've looked at:
Generic htaccess redirect www to non-www
apache redirect from non www to www
My SSL cert lists both example.com and www.example.com. Here is the code in my apache2.conf file that I've been trying to add the redirect:
<Directory /home/tim/examplepath>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sort-url.php?rt=$1
</Directory>
<VirtualHost XXX.XXX.XX.XXX:12345>
ServerName example.com
Redirect / https://example.com/
</VirtualHost>
<VirtualHost XXX.XXX.XX.XXX:80>
ServerName example.com
Redirect / https://example.com/
</VirtualHost>
<VirtualHost XXX.XXX.XX.XXX:123>
ServerName example.com
DocumentRoot /home/tim/examplepath/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/example.com.crt
SSLCertificateKeyFile /etc/ssl/certs/example.key
SSLCertificateChainFile /etc/ssl/certs/sf_bundle.crt
</VirtualHost>
I would like everything to redirect to https://example.com/sort-url.php?rt=$1 where I can then determine which page to show based on the variable $1.
Can someone please tell what I need to do? ServerAlias in the and the 301 redirect inside of the haven't worked for me.
Thank you in advance!
Tim