Skip to main content
Source Link

301 redirect non-www to www in subdirectories

I am in a unique situation where I have multiple instances of Joomla setup under my primary domain in different subdirectories.

For example:

mydomain.com = Joomla instance
mydomain.com/subdirectory1 = Another Joomla instance
mydomain.com/subdirectory2 = Another Joomla instance

On the main Joomla instance I was able to forward my non-www pages to www using the htaccess file and this code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule (.*) http://www.mydomain.com/$1 [L,R=301]

I want to also forward non-www pages to www pages on all of the subdirectories.

What would be the best way to achieve this? Since each subdirectory has it's own Joomla instance, is there something I can just add to each of the htaccess files?

Thank you so much for your help!