I understand somewhat similar questions have been asked and yes I did and read all the relevant answers and tried it all for quite some time. However I can't figure out what the error is. I believe the script is correct. What is going on?
My problem is that I can't make the trailing slash appear in the url. Therefore I get 2 versions of the same page. (Duplicate content issue?) For example:
htttps://www.example.com/faq.php
&
htttps://www.example.com/faq.php/
I had hoped to always automatically add the trailing slash so there is no other version of the same.
Here is my .htaccess code:
<IfModule mod_rewrite.c>
RewriteEngine On
#Redirect anything to http://www (WORKING FINE)
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
#Redirect anything to https (WORKING FINE)
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Redirect to trailing slash (NOT WORKING!)
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://example.com/$1/ [L,R=301]
#Redirect /index.php to / (WORKING FINE)
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
</IfModule>
Also one more question on the same.
How is it that when I go to my domain where the trailing slash "/" is not showing in the url. Then I copy & paste it into a text editor it comes up as https://www.example.com/ with the trailing slash.
And yet the same does not happen when I copy/paste an url from any subpage as above mentioned for example /faq.php (NOT shwoing as: /faq.php/).
I know that the trailing slash in the root domain is necessary to make a HTTP request valid but why aren't the browsers showing it? Just an aesthetic thing? Anyway I am more concerned about the above question.
Thanks a lot for the help!