There is a construction in .htaccess :

 RewriteRule ^/?(.*)/$ index.php?blog_name=$1&%{QUERY_STRING} 

At the output, URLs of the form are obtained: http://site.zon/name/ , but if you remove the slash at the end, you get 404, i.e. http://site.zon/name = 404 .

How can this be fixed with PHP or the same RewriteRule ?

    2 answers 2

     RewriteCond %{REQUEST_URI} !/$ RewriteCond %{REQUEST_URI} !\. RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L] 

    try this This script will redirect yours from an address without a slash to an address with a slash (which is at the end).

    • Wow, Wow. helped and works great. thank you, lampa. - bande
    • there is one oddity: the main one now has two slashes: // how to get rid of it? - bande
     RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !example.php RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*[^/])$ $1/ [L,R=301] 

    It helped me.


    • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky