Answers.Body: <blockquote>
  <p>I have Craft public files set up within subdirectories of a primary domain’s web root.</p>
  <p>The following .htaccess rules allow for the public_html subdirectory to <strong>act as the new web root.</strong></p>
  </blockquote>
  <p>Is there a <em>reason</em> you're doing it this way? The <code>.htaccess</code> you have is only rewriting the content, it's not actually setting the web root. You're basically asking Apache to serve content out of the root for your other domain. There's only a couple circumstances I can think of where you'd need to <em>actually</em> do that (<em>mirroring</em> a domain for example but that's not something you probably want to do here).</p>
  <p>For that, you need to set Apache's <a href="https://httpd.apache.org/docs/2.4/mod/core.html#documentroot" rel="nofollow noreferrer"><code>DocumentRoot</code></a> properly for your second domain.</p>
  <p>It sounds like you have a  <a href="http://support.hostgator.com/articles/cpanel/document-root-changes" rel="nofollow noreferrer">CPanel</a> based setup, where it's common for it to put add-on domains inside of the web root of the primary domain by default.  I'm not sure how the document root got changed to the primary domain but you need to set the document root of the add-on domain to the proper place (in Cpanel it's usually the Modify Domain function).</p>
  <p>What you type in depends on your path but it's probably set to just <code>public_html</code> now. You want <code>public_html/example.com/public_html/</code>.</p>
  <p>That'll get you back to a properly functioning setup.  Then just use Craft's default <code>.htaccess</code> file.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-16T18:35:06.720Z
Answers.Text: I really appreciate this. There is a reason; but now I'm weighing whether or not it's worth it. Basically, I wanted to see if it was possible. If it were it'd help to keep the .gitignore file clean of all the server's default files below web root. :) Just laziness trying to find a solution.
  
  It is cpanel, but this is for the primary domain so I can't modify the domain.
Answers.UserDisplayName: Stephen Callender
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-16T18:59:08.333Z
Answers.Text: Depending on what you're trying to do, some hosting companies allow tweaking of cpanel's defaults, then you can exercise more control. Worst case, get a vps from linode or droplet from digital ocean and do whatever you want including proper git deployment ;)
Answers.UserDisplayName: RitterKnight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-16T17:52:09.700Z
Answers.LastActivityDate: 2016-02-16T18:02:21.863Z
Answers.LastEditDate: 2020-06-17T08:56:27.903Z
Answers.UserDisplayName: RitterKnight
Body: <p>I have Craft public files set up within subdirectories of a primary domain’s web root.</p>
  
  <pre><code>public_html/ # default web root
  public_html/example.com/public_html/ # Craft public files here
  </code></pre>
  
  <p>The following .htaccess rules allow for the <code>public_html</code> subdirectory to act as the new web root. This is the .htaccess within the first <code>public_html</code> directory.</p>
  
  <pre><code>RewriteEngine on
  
  RewriteCond %{HTTP_HOST} ^example.com$
  RewriteCond %{REQUEST_URI} !^/example.com/public_html/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /example.com/public_html/$1
  
  RewriteCond %{HTTP_HOST} ^example.com$
  RewriteRule ^(/)?$ example.com/public_html/index.php?p=$1 [QSA,L]
  </code></pre>
  
  <p>It works until I go to example.com/admin.</p>
  
  <p>I can login and cp works, but the URL is <code>http://example.com/example.com/public_html/admin/dashboard</code></p>
  
  <p>I'd like to remove the subdirectories from the above admin URL for mere aesthetic reasons, but can’t seem to nail it down.</p>
  
  <p>Note: When going directly to <code>http://example.com/admin/dashboard</code>, for example, the URL remains as is, but all the internal links have the subdirectories.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-16T17:22:13.927Z
Comments.Text: Are you using cpanel by chance?
Comments.UserDisplayName: RitterKnight
Tags: <control-panel><htaccess>
Title: Remove subdirectories from admin URL with .htaccess
ThreadText: # Remove subdirectories from admin URL with .htaccess
  
  (Asked by: username_0 on 2016-02-16)
  
  I have Craft public files set up within subdirectories of a primary domain’s web root.
  
  ```
  public_html/ # default web root
  public_html/example.com/public_html/ # Craft public files here
  
  ```
  
  The following .htaccess rules allow for the `public_html` subdirectory to act as the new web root. This is the .htaccess within the first `public_html` directory.
  
  ```
  RewriteEngine on
  
  RewriteCond %{HTTP_HOST} ^example.com$
  RewriteCond %{REQUEST_URI} !^/example.com/public_html/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /example.com/public_html/$1
  
  RewriteCond %{HTTP_HOST} ^example.com$
  RewriteRule ^(/)?$ example.com/public_html/index.php?p=$1 [QSA,L]
  
  ```
  
  It works until I go to example.com/admin.
  
  I can login and cp works, but the URL is `http://example.com/example.com/public_html/admin/dashboard`
  
  I'd like to remove the subdirectories from the above admin URL for mere aesthetic reasons, but can’t seem to nail it down.
  
  Note: When going directly to `http://example.com/admin/dashboard`, for example, the URL remains as is, but all the internal links have the subdirectories.
  
  **Tags:** control-panel, htaccess
  
  > **Comments:**
  > **username_1**: Are you using cpanel by chance?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-02-16. Score: 3 | Accepted answer
  
  > I have Craft public files set up within subdirectories of a primary domain’s web root.
  >
  > The following .htaccess rules allow for the public\_html subdirectory to **act as the new web root.**
  
  Is there a *reason* you're doing it this way? The `.htaccess` you have is only rewriting the content, it's not actually setting the web root. You're basically asking Apache to serve content out of the root for your other domain. There's only a couple circumstances I can think of where you'd need to *actually* do that (*mirroring* a domain for example but that's not something you probably want to do here).
  
  For that, you need to set Apache's [`DocumentRoot`](https://httpd.apache.org/docs/2.4/mod/core.html#documentroot) properly for your second domain.
  
  It sounds like you have a [CPanel](http://support.hostgator.com/articles/cpanel/document-root-changes) based setup, where it's common for it to put add-on domains inside of the web root of the primary domain by default. I'm not sure how the document root got changed to the primary domain but you need to set the document root of the add-on domain to the proper place (in Cpanel it's usually the Modify Domain function).
  
  What you type in depends on your path but it's probably set to just `public_html` now. You want `public_html/example.com/public_html/`.
  
  That'll get you back to a properly functioning setup. Then just use Craft's default `.htaccess` file.
  
  > **Comments:**
  > **username_0**: I really appreciate this. There is a reason; but now I'm weighing whether or not it's worth it. Basically, I wanted to see if it was possible. If it were it'd help to keep the .gitignore file clean of all the server's default files below web root. :) Just laziness trying to find a solution.  It is cpanel, but this is for the primary domain so I can't modify the domain.  
  > **username_1**: Depending on what you're trying to do, some hosting companies allow tweaking of cpanel's defaults, then you can exercise more control. Worst case, get a vps from linode or droplet from digital ocean and do whatever you want including proper git deployment ;)  
  
  ---
  
  