I am trying to understand how redirects & rewrites work in a shared-hosting configuration considering that there are two different functions going on simultaneously, this is cPanel and .htaccess manual scripting. There are 4 possibilities:
1 - My original domain: this is the domain I opened a shared account with. If I set up apps in a different directory than public_html then I need to manually re-direct/re-write to that directory through .htaccess. I cannot do this through cPanel. This correct?
2 - Parked Domains: I can go through cPanel, which will write into the .htaccess pointing to the appropriate directory I selected in the Parked Domain page. But what will happen if I write into .htaccess directly and not go through cPanel? I am assuming that there will be a disconnect since the nameservers will be pointing to my hosting company but the local DNS would not resolve to my public_html directory since cPanel did not set it up. Therefore, it is a bad idea to write into .htaccess directly for Parked Domains, correct?
3 - Add-on Domains: I am forced to go through cPanel only since it does not write into .htaccess. I am guessing that cPanel adds a resolution for that domain to my public_html directory. If I try to write into .htaccess directly, again, there will be a disconnect since the nameservers will be pointing to my hosting company but the local DNS would not resolve to my public_html directory since cPanel did not set it up. Therefore, it is a bad idea to write into .htaccess directly for Add-On Domains, correct?
4 - Sub-Domains: same as Add-On Domains.
I don't quite get it why cPanel would write into .htacces for Parked, but not for Add-Ons or Subs.
But, more importantly, can I trust cPanel? For example, for a main domain redirect, I would have the following code:
RewriteCond %{THE_REQUEST} /s1/j1/
RewriteRule ^s1/j1/(.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(*\.example1\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example1\.com)$ [NC]
RewriteRule (.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example1.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L]
which would take care of all the nuances dealing with improper namings, HTTP v1.0, etc,, in addition to the rewrite.
However, for Parked, Add-Ons and Subs, I have no clue if all these nunances are taken care of by cPanel, or do I need to add into the .htaccess file?
1 - My original domain: this is the domain I opened a shared account with. If I set up apps in a different directory than public_html then I need to manually re-direct/re-write to that directory through .htaccess. I cannot do this through cPanel. This correct?
2 - Parked Domains: I can go through cPanel, which will write into the .htaccess pointing to the appropriate directory I selected in the Parked Domain page. But what will happen if I write into .htaccess directly and not go through cPanel? I am assuming that there will be a disconnect since the nameservers will be pointing to my hosting company but the local DNS would not resolve to my public_html directory since cPanel did not set it up. Therefore, it is a bad idea to write into .htaccess directly for Parked Domains, correct?
3 - Add-on Domains: I am forced to go through cPanel only since it does not write into .htaccess. I am guessing that cPanel adds a resolution for that domain to my public_html directory. If I try to write into .htaccess directly, again, there will be a disconnect since the nameservers will be pointing to my hosting company but the local DNS would not resolve to my public_html directory since cPanel did not set it up. Therefore, it is a bad idea to write into .htaccess directly for Add-On Domains, correct?
4 - Sub-Domains: same as Add-On Domains.
I don't quite get it why cPanel would write into .htacces for Parked, but not for Add-Ons or Subs.
But, more importantly, can I trust cPanel? For example, for a main domain redirect, I would have the following code:
RewriteCond %{THE_REQUEST} /s1/j1/
RewriteRule ^s1/j1/(.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(*\.example1\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example1\.com)$ [NC]
RewriteRule (.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example1.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L]
which would take care of all the nuances dealing with improper namings, HTTP v1.0, etc,, in addition to the rewrite.
However, for Parked, Add-Ons and Subs, I have no clue if all these nunances are taken care of by cPanel, or do I need to add into the .htaccess file?