Hello everyone, tell me how to make a redirect "without the last slash" with "last slash", as well as "/index.php" in "/". Did so, but for some reason it does not work

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^mysite\.ru$ [NC] RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ \/index\.php\ HTTP\/ RewriteRule (.*) http://www.mysite.ru/$1 [R=301,L] RewriteRule ^index\.php$ http:\/\/%{HTTP_HOST}\/ [R=301,QSA,L] php_flag zlib.output_compression On php_value zlib.output_compression_level 5 
  • Look here for something useful you can find [tricks with the .htaccess file] [1] [1]: ruseller.com/search.php?s=htaccess - webkostya
  • But in general, is it right written by me? - karr
  • If you don’t want the address to be mysite.ru/index.php You just don’t need to specify in the index.php link just write <a href="/"> Home </> - webkostya

1 answer 1

After $1 add a slash:

 RewriteRule ^(.*)$ http://www.mysite.ru/$1/ [R=301,L] 

And for index.php line must be moved before the previous one, something like this:

 RewriteRule /index\.php$ / 

This will change the end of the line /blabla/index.php to /blabla/ , but I did not check. The result should be something like this:

 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^mysite\.ru$ [NC] RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ \/index\.php\ HTTP\/ RewriteRule /index\.php$ / RewriteRule ^(.*)$ http://www.mysite.ru/$1/ [R=301,L]