How to put a redirect from site.ru// to site.ru/ ? Not able to configure at all.

 # MODX supports Friendly URLs via this .htaccess file. php_flag display_errors on RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
  • one
    what web server? - Memoizer
  • Hosting on masterhost in principle, you can pick . Htaccess - reddyk
  • @reddyk And why do you need it? Standard error 404 will be just right. Or indicate whether you are using the Apache rewrite module, if so, what rules are already installed there. Requires more specifics. - VisioN
  • for search engines - reddyk

2 answers 2

For apache mod_rewrite:

 # remove trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s] RewriteRule ^(.+?)/$ /$1 [R=301,L] 

For nginx:

 rewrite ^/(.*)/$ /$1 permanent; 

More details:

  • set does not work - reddyk

It seems to me that the situation in which redirection from site.ru // is required requires consideration. We must get rid of the cause, not the effect.

  • would be happy to get rid of this problem - reddyk
  • Describe the situation in which there is an appeal to site.ru// - TarasovSA