Redirects & Rewrites - .htaccess & cPanel - questions


globus999
 Share

Recommended Posts

I am trying to understand how redirects & rewrites work considering that there are two different functions going on simultaneously.

 

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.

 

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 hawkhost 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 hawkhost 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 inproper 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?

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share