I'm using apache2 and laravel so I put this code inside .htaccess
on /public
folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/?(blog|dont/you|brave-to|fvck|me)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
code above is working only if url spesific with the /url
An example https://mywebsite.com/blog
or https://mywebsite.com/dont/you
so with this RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
will redirect you to get tailling slash
so will be https://mywebsite.com/blog/
But when I want to add dynamic slug this not working
link test
I mean, I need to add tailling slash after end of slug
following by blog
an example if the url like this https://mywebsite.com/blog/hey-this-dynamic-slug
this should be https://mywebsite.com/blog/hey-this-dynamic-slug/
I have to add this condition and rule
RewriteCond %{THE_REQUEST} !\s/(?:blog/)\S+\s [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
https://htaccess.madewithlove.com?share=47516f5c-b5c6-49e9-87fa-3b83cec864fc
but this will force all with /
as you can see when I try to change blog
with random text this rule force to add /
I just need to force add tailling slash only for spesific url and after spesific url