OK, so I want to replace example.com/x with www.example.com/X. When I follow the in-line tutorials I get: www.example.comX
Here is the .htaccess snipet
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com$1 [R=301]
Since you’re doing this inside a .htaccess file (as opposed to the main server httpd.conf), the rules are slightly different. mod_rewrite will remove everything up to the current directory level and then apply the match. So your (.*) pattern is matching ‘X’ instead of ‘/X’.
There’s a confusingly-worded explanation of this in the mod_rewrite documentation here:
So, two possible fixes:
Put this in the main httpd.conf, which is where it should probably be if you’re doing redirects at the server root.