I have searched around for a while and had a go at tweaking this file myself and I’m almost there but there is one case which I can’t figure out…
How to get both a www. AND a forward slash at the same time
If I type in spectrl.com, it redirects to http://www.spectrl.com CORRECT – Adds www.
If I type in http://www.spectrl.com/ebaycalculator it redirects to http://www.spectrl.com/ebaycalculator/ CORRECT – Adds /
But if I type in spectrl.com/ebaycalculator I get a 404 error when it should go to http://www.spectrl.com/ebaycalculator/
Here’s my .htcaccess file, kept at the root:
RewriteBase /
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://spectrl.com/$1/ [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Thanks
After removing and re-uploading .htaccess and then clearing the cache, everything seems to be working as intended using my original code in the question.
Hope this will be helpful for someone else.