I want redirect all traffic to example.com/*
to be redirected to www.example.com/*
I found How can I redirect any ServerAlias to the respective ServerName? which handles the topic in question and did what was recommended in the answer with four upvotes:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com [nocase]
RewriteRule ^(.*)$ http://www.example.com$1 [last,redirect=301]
However, this redirect traffic going to http://example.com/subdirectory
to http://www.example.com
and not to http://www.example.com/subdirectory
as desired.
Any medication on this issue?