I have 2 websites, one hosted in a root directory (root.com), and one hosted in a subdirectory (root.com/sub). I use Host Gator shared, cPanel, and these are both WordPress websites.
I have recently purchased a domain and changed the DNS for the subdirectory website (root.com/sub to sub.com).
I want to create a 301 redirect for all traffic going to root.com/sub to sub.com
What I have tried for both sub.com/.htaccess and root.com/.htaccess:
RewriteEngine ON
RewriteCond %{HTTP_HOST} root\.com
RewriteCond %{REQUEST_URI} sub
RewriteRule ^sub(.*)$ http://sub.com/$1 [R=301,L]
I have tested it with http://htaccess.madewithlove.be/ and it works there, but it has no effect when on the server.