Answers.Body: <p>I don't think this is particularly <strong>Craft CMS</strong> specific problem. Just Apache .htaccess rules in general. I would try to search for and answer of Stack Overflow. I have a strong feeling it's been answered there already.</p>
  
  <p><a href="https://stackoverflow.com/questions/7780859/htaccess-rewrite-to-force-trailing-slash-at-the-end">https://stackoverflow.com/questions/7780859/htaccess-rewrite-to-force-trailing-slash-at-the-end</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-17T19:47:27.557Z
Answers.LastActivityDate: 2018-10-17T19:55:39.400Z
Answers.LastEditDate: 2018-10-17T19:55:39.400Z
Answers.UserDisplayName: Alex Roper
Body: <p>After redirecting a website to https environment I had the difficulty that .php/ was added to the url which resulted in double content. I have been able to get past this mistake but now I need to force a /  on in the end if the url’s does not have that yet.</p>
  
  <p>Example</p>
  
  <pre><code>Domainname.com/example/
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Domainname.com/example
  </code></pre>
  
  <p>Are now visible in Google. I want only the one with the /</p>
  
  <p>Current .htaccess is:</p>
  
  <pre><code>DirectoryIndex index.php
  ErrorDocument 404 /404.html
  
  RewriteEngine On
  ### START WWW &amp; HTTPS
  # ensure www.
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  # ensure https
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  ### END WWW &amp; HTTPS
  RewriteBase / 
  RewriteRule ^([^.?]+[^.?/])$ $1/ [R=301,L]
  RewriteCond %{DOCUMENT_ROOT}/$1.php -f
  RewriteRule ^(.*[^/])/?$ /$1.php [QSA,L]
  
  RewriteRule ^index\.php$ / [R=301,L]
  
  #1)externally redirect "/file.php" to "/file"   
  RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
  RewriteRule ^ /%1 [NC,L,R]
  #2)Internally map "/file" back to "/file.php"
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*?)/?$ /$1.php [NC,L]
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-17T19:48:42.583Z
Comments.Text: I'm voting to close this question as off-topic because it belongs on another site in the Stack Exchange network.
Comments.UserDisplayName: Alex Roper
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-19T16:02:53.303Z
Comments.Text: Cross-site post on Webmasters: https://webmasters.stackexchange.com/questions/118502/htaccess-please-help-getting-trailing-slash-back
Comments.UserDisplayName: MrWhite
Tags: <redirect><htaccess><https><redirection>
Title: Forcing a / with .htaccess
ThreadText: # Forcing a / with .htaccess
  
  (Asked by: username_0 on 2018-10-17)
  
  After redirecting a website to https environment I had the difficulty that .php/ was added to the url which resulted in double content. I have been able to get past this mistake but now I need to force a / on in the end if the url’s does not have that yet.
  
  Example
  
  ```
  Domainname.com/example/
  
  ```
  
  and
  
  ```
  Domainname.com/example
  
  ```
  
  Are now visible in Google. I want only the one with the /
  
  Current .htaccess is:
  
  ```
  DirectoryIndex index.php
  ErrorDocument 404 /404.html
  
  RewriteEngine On
  ### START WWW & HTTPS
  # ensure www.
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  # ensure https
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  ### END WWW & HTTPS
  RewriteBase / 
  RewriteRule ^([^.?]+[^.?/])$ $1/ [R=301,L]
  RewriteCond %{DOCUMENT_ROOT}/$1.php -f
  RewriteRule ^(.*[^/])/?$ /$1.php [QSA,L]
  
  RewriteRule ^index\.php$ / [R=301,L]
  
  #1)externally redirect "/file.php" to "/file"   
  RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
  RewriteRule ^ /%1 [NC,L,R]
  #2)Internally map "/file" back to "/file.php"
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.*?)/?$ /$1.php [NC,L]
  
  ```
  
  **Tags:** redirect, htaccess, https, redirection
  
  > **Comments:**
  > **username_1**: I'm voting to close this question as off-topic because it belongs on another site in the Stack Exchange network.  
  > **username_2**: Cross-site post on Webmasters: https://webmasters.stackexchange.com/questions/118502/htaccess-please-help-getting-trailing-slash-back  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-17. Score: 1
  
  I don't think this is particularly **Craft CMS** specific problem. Just Apache .htaccess rules in general. I would try to search for and answer of Stack Overflow. I have a strong feeling it's been answered there already.
  
  <https://stackoverflow.com/questions/7780859/htaccess-rewrite-to-force-trailing-slash-at-the-end>
  
  
  ---
  
  