1

I've recently appended the trailing slash at the end of the URL by using this .htaccess code:

#add trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]

When I copy the URL from any element from the page, like this for example, it doesn't show trailing slash in the end. Why?

enter image description here

2

but when I copy the url from any element from the page like this for example, It doesn't show Trailing slash in the end. Why?

The .htaccess directive you posted doesn't change your HTML source, it simply redirects HTTP requests sent to your server.

how to add trailing slash everywhere, not just in the main url search bar

You need to edit the HTML source / generation.

(You appear to have since modified the HTML source so that the links do now include the trailing slash?)

| improve this answer | |
  • where can i get a http access code for the http source? – Ankit raghu. Feb 25 at 4:35
  • no, i had a plugin called permalink manager having an option to add the permalink. But i do want to add it via http access code. – Ankit raghu. Feb 25 at 4:37
  • "where can i get a http access code for the http source?" - I assume by "http access", you are referring to .htaccess. You can't - it doesn't work like that. You can't change the HTML source using .htaccess. – MrWhite Feb 25 at 10:53
  • "But i do want to add it via http access code." - What makes you think you "want" to do that? You should add the trailing slash using your plugin (or CMS) etc. – MrWhite Feb 25 at 10:55
  • 1
    I don't have any problem with the trailing slash now.. I think, I'll use plugin. thanks for the help – Ankit raghu. Feb 25 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.