Answers.Body: <p>I might be way off here, but if you are wanting to run Craft as your main front-end, could you not place the Craft <code>index.php</code> in the root of the site and then you CRM in a sub-folder of its own?</p>
  
  <p>If you have all you CRM stuff in its own sub-folder, Craft should just ignore that folder as it physically exists. If you've got specific things you need to have in your <code>.htaccess</code> file for you CRM, you could have that <code>.htaccess</code> in the sub-folder, rather than the root. That way you can just have the standard Craft <code>.htaccess</code> file in the root of the site.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-20T15:42:15.213Z
Answers.Text: Interesting. It was set up the way it is as it's essentially two github repos, but you're right, that might make more sense. I'll give this a go, thanks.
Answers.UserDisplayName: Jammooka
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-21T12:17:02.197Z
Answers.Text: This was the way to go - took a bit of reconfiguration, but far simpler outcome. Thanks!
Answers.UserDisplayName: Jammooka
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-21T13:02:35.063Z
Answers.Text: Great stuff glad I could help :)
Answers.UserDisplayName: Steve Holland
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-20T12:39:57.233Z
Answers.LastActivityDate: 2017-06-20T12:39:57.233Z
Answers.UserDisplayName: Steve Holland
Body: <p>I'm rebuilding a website which needs to run Craft CMS as the main frontend and a bespoke CRM system at the same domain.</p>
  
  <p>The file setup is basically</p>
  
  <ul>
  <li>public_html
  
  <ul>
  <li>cms</li>
  <li>crm</li>
  </ul></li>
  </ul>
  
  <p>To make things a bit more complicated, certain parts of the CRM have to be publically accessible, so there are a few different URL structures that need to run from the CRM, and the rest from Craft. Also, the images/scripts are in the cms folder, so I need to get those to work without cms in the URL.</p>
  
  <p>For the most part this is working lovely, but I can't get force /cms/ to be removed from the URL, so whilst the site works fine without it, it's live on 2 different URLs.</p>
  
  <p>I have the  with the following code:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  
      # Force the root to match slug of home page
      # This is the only way I can get the home page to
      # show on the root, as it's within a structure
      RewriteRule ^$ /__home__
  
      # Get rid of /cms (this doesn't work)
      RewriteRule ^cms/?(.+)$ /$1 [R=301]
  
      # Sort out frontend files
      RewriteCond %{REQUEST_URI} /assets/.*
      RewriteCond %{REQUEST_URI} !/assets/admin/.*
      RewriteCond %{REQUEST_URI} !/cms/.*
      RewriteCond %{REQUEST_URI} !/crm/web/.*
      RewriteRule ^(.*\.(gif|jpg|jpeg|bmp|svg|png|css|js|json|pdf|eot|woff|woff2|ttf|otf))$ /cms/$1 [QSA,L]
  
      # Sort out admin files
      RewriteCond %{REQUEST_URI} /assets/admin/.*
      RewriteCond %{REQUEST_URI} !/cms/.*
      RewriteCond %{REQUEST_URI} !/crm/web/.*
      RewriteRule ^(.*\.(gif|jpg|jpeg|bmp|svg|png|css|js|json|pdf|eot|woff|woff2|ttf|otf))$ /crm/web/$1 [QSA,L]
  
      # Send would-be 404 requests to Craft
      # Need to exclude any that should route to the CRM
      # Any that we exclude, we then need to route below
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteCond %{REQUEST_URI} !^/manager/?(.*)$ [NC]
      RewriteCond %{REQUEST_URI} !^/forms/(.+)$ [NC]
      RewriteCond %{REQUEST_URI} !^/partners/?(.*)$ [NC]
      RewriteCond %{REQUEST_URI} !^$ [NC]
      RewriteRule (.+) /cms/index.php/$1 [QSA,L]
  
      # CRM Admin
      RewriteCond %{REQUEST_URI} ^/manager/?(.*)$ [NC]
      RewriteRule ^manager/?(.*) /crm/web/app.php [QSA,L]
  
      # Quote Forms
      RewriteCond %{REQUEST_URI} ^/forms/(.+)$ [NC]
      RewriteRule ^forms/(.+) /crm/web/app.php [QSA,L]
  
      # Signup Forms
      RewriteCond %{REQUEST_URI} ^/partners/?(.*)$ [NC]
      RewriteRule ^partners/?(.*) /crm/web/app.php [QSA,L]
  
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>So I'm fairly sure that the line <code>RewriteRule ^cms/?(.+)$ /$1 [R=301]</code> would work, but the default Craft logic is somehow preventing it - if I comment out the default craft section, then it removes cms from the URLs, but obviously nothing is routed through Craft, so 404s all round.</p>
  
  <p>I'm completely stumped at this point, so any help would be appreciated!</p>
  
Tags: <redirect><htaccess>
Title: .htaccess for Craft CMS - removing segment from URL
ThreadText: # .htaccess for Craft CMS - removing segment from URL
  
  (Asked by: username_0 on 2017-06-20)
  
  I'm rebuilding a website which needs to run Craft CMS as the main frontend and a bespoke CRM system at the same domain.
  
  The file setup is basically
  
  * public\_html
    + cms
    + crm
  
  To make things a bit more complicated, certain parts of the CRM have to be publically accessible, so there are a few different URL structures that need to run from the CRM, and the rest from Craft. Also, the images/scripts are in the cms folder, so I need to get those to work without cms in the URL.
  
  For the most part this is working lovely, but I can't get force /cms/ to be removed from the URL, so whilst the site works fine without it, it's live on 2 different URLs.
  
  I have the with the following code:
  
  ```
  <IfModule mod_rewrite.c>
  
      # Force the root to match slug of home page
      # This is the only way I can get the home page to
      # show on the root, as it's within a structure
      RewriteRule ^$ /__home__
  
      # Get rid of /cms (this doesn't work)
      RewriteRule ^cms/?(.+)$ /$1 [R=301]
  
      # Sort out frontend files
      RewriteCond %{REQUEST_URI} /assets/.*
      RewriteCond %{REQUEST_URI} !/assets/admin/.*
      RewriteCond %{REQUEST_URI} !/cms/.*
      RewriteCond %{REQUEST_URI} !/crm/web/.*
      RewriteRule ^(.*\.(gif|jpg|jpeg|bmp|svg|png|css|js|json|pdf|eot|woff|woff2|ttf|otf))$ /cms/$1 [QSA,L]
  
      # Sort out admin files
      RewriteCond %{REQUEST_URI} /assets/admin/.*
      RewriteCond %{REQUEST_URI} !/cms/.*
      RewriteCond %{REQUEST_URI} !/crm/web/.*
      RewriteRule ^(.*\.(gif|jpg|jpeg|bmp|svg|png|css|js|json|pdf|eot|woff|woff2|ttf|otf))$ /crm/web/$1 [QSA,L]
  
      # Send would-be 404 requests to Craft
      # Need to exclude any that should route to the CRM
      # Any that we exclude, we then need to route below
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
      RewriteCond %{REQUEST_URI} !^/manager/?(.*)$ [NC]
      RewriteCond %{REQUEST_URI} !^/forms/(.+)$ [NC]
      RewriteCond %{REQUEST_URI} !^/partners/?(.*)$ [NC]
      RewriteCond %{REQUEST_URI} !^$ [NC]
      RewriteRule (.+) /cms/index.php/$1 [QSA,L]
  
      # CRM Admin
      RewriteCond %{REQUEST_URI} ^/manager/?(.*)$ [NC]
      RewriteRule ^manager/?(.*) /crm/web/app.php [QSA,L]
  
      # Quote Forms
      RewriteCond %{REQUEST_URI} ^/forms/(.+)$ [NC]
      RewriteRule ^forms/(.+) /crm/web/app.php [QSA,L]
  
      # Signup Forms
      RewriteCond %{REQUEST_URI} ^/partners/?(.*)$ [NC]
      RewriteRule ^partners/?(.*) /crm/web/app.php [QSA,L]
  
  </IfModule>
  
  ```
  
  So I'm fairly sure that the line `RewriteRule ^cms/?(.+)$ /$1 [R=301]` would work, but the default Craft logic is somehow preventing it - if I comment out the default craft section, then it removes cms from the URLs, but obviously nothing is routed through Craft, so 404s all round.
  
  I'm completely stumped at this point, so any help would be appreciated!
  
  **Tags:** redirect, htaccess
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-20. Score: 1 | Accepted answer
  
  I might be way off here, but if you are wanting to run Craft as your main front-end, could you not place the Craft `index.php` in the root of the site and then you CRM in a sub-folder of its own?
  
  If you have all you CRM stuff in its own sub-folder, Craft should just ignore that folder as it physically exists. If you've got specific things you need to have in your `.htaccess` file for you CRM, you could have that `.htaccess` in the sub-folder, rather than the root. That way you can just have the standard Craft `.htaccess` file in the root of the site.
  
  > **Comments:**
  > **username_0**: Interesting. It was set up the way it is as it's essentially two github repos, but you're right, that might make more sense. I'll give this a go, thanks.  
  > **username_0**: This was the way to go - took a bit of reconfiguration, but far simpler outcome. Thanks!  
  > **username_1**: Great stuff glad I could help :)  
  
  ---
  
  