Support

Admin Tools

#14391 htaccess setting www for root level domain and non-www for subdomains

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by nicholas on Saturday, 15 December 2012 01:40 CST

nemmar

Mandatory information about my setup:

Have I read the related troubleshooter articles above before posting (which pages?)? Ye
Have I searched the tickets before posting? Yes, I found one but it dealt with httpS
Have I read the documentation before posting (which pages?)? Yes
Joomla! version: 2.5.8
PHP version: 5.3.19
MySQL version: 5.5.27-cll
Host: dedicated server
Admin Tools version: 2.4.3
 
Description of my issue:
Nicholas,

Using AT Pro, I have my .htaccess file set to redirect Non-www URL's to use the www version of the URLs for all pages in the root level domain.

For my subdomains on that same root level domain: I have my .htaccess file set to redirect www URL's to use the Non-www version of the URLs for all pages in the subdomains.   The reason I did that is because I've read some articles online that you should not use the www for subdomain URLs. I also had both www and non-www root level domain pages indexed by Google a while ago and set the Google Webmaster Tools setting to www for my preferred domain.   1) Can you tell me if that is the correct .htaccess Maker setting and if I should not use the www for subdomain URLs? Or does it not matter if I use have subdomain redirects of non-www to www?   2) Or should I just use non-www for both root level and subdomains in the .htaccess Maker settings?   My guess is there's a good reason to redirect to use the www in root level domains, because before I posted I tried non-www on your domain and it redirected the page to the www address. Since you're a genius with Internet and website security, I figured you would know the best setting to use.   Let me know if you have any advice on this. Thank you!!

nicholas
Akeeba Staff
Manager

Already documented here: https://www.akeebabackup.com/documentation/troubleshooter/atsubdomains.html

My advice: never, EVER, store your subdomains as subdirectories under your main site's root. It's a bad, bad, bad idea and will lead to errors which are almost impossible to solve without making a bad compromise on the main site or the sites in the subdirectories.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

nemmar

Nicholas,

I did follow the instructions on that page to setup the subdomains. I temporarily allowed access to the subdomain folders to the main domain .htaccess file. Then after setting up the subdomain site I removed the allowed access in the root site and created the .htaccess file with AT Pro for the subdomain.

I'm not getting any errors (none that I know of) by having the subdomains as subdirectories of the main site's root. But I asked the web hosting tech support if it was possible to setup the subdomains of the main site in a separate CPanel so they would be located in their own root directory and not be subdirectories. The hosting support said you can't do that if they are subdomains. So I guess from what you're telling me they are incorrect (this isn't the first time my hosting support has given me bad advice).

Can you tell me what you would recommend as a more secure and better way to setup the subdomains with the best security of AT Pro? I don't know why it's bad to have the subdomains as subdirectories but you're the expert in this field so I'm sure there must be a good reason you're telling me that advice.

Thanks for any advice on this!

nicholas
Akeeba Staff
Manager

Here's what happens. Your subdomain is in a subdirectory of the main site. The .htaccess files are cascading through the directory structure. This means that when your web server is trying to serve a file from the subdomain's root it will look for a .htaccess in that directory. It will also look for a .htaccess file in the directory above it (the main site's root) and mix its settings with those of the subdomain's root. This is the problem with having subdomains in subdirectories of the main site. The workaround is to remove the .htaccess from the main site, while at the same time screwing up its functionality (forget SEF URLs without .htaccess, password protected directories, non-www to www redirection etc) and security.

So, I will say this again: never, EVER, store your subdomains as subdirectories under your main site's root. It's a bad, bad, bad idea and will lead to errors which are almost impossible to solve without making a bad compromise on the main site or the sites in the subdirectories.

But I asked the web hosting tech support if it was possible to setup the subdomains of the main site in a separate CPanel so they would be located in their own root directory and not be subdirectories. The hosting support said you can't do that if they are subdomains.

Lies, damn lies and incompetent hosting support! Of course you can have a subdomain which IS NOT a subdirectory of the main site. The procedure goes like that:

  • Create a new directory in your account's root (where your public_html directory lives). I prefer the convention public_subdomainname, e.g. public_foobar for foobar.example.com
  • Create the subdomain in cPanel. When it asks you for the subdomain's root just select your custom top level directory, e.g. public_foobar

It's that simple. I am on a cPanel-powered server myself and do hav subdomains and add-on domains on two of my sites. I think I know what I'm talking about ;)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!