如何301将domain.com/重定向到domain.com

时间:2018-07-25 12:22:37

标签: .htaccess redirect http-status-code-301

如何301将domain.com/重定向到domain.com,因此,如果有人以/开头打开domain.com/,则我们需要不带/结尾的301重定向到domain.com,这将影响所有页面:

domain.com/username/到domain.com/username domain.com/tag/lol/到domain.com/tag/lol

1 个答案:

答案 0 :(得分:-1)

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)/$ /$1 [L,R=301]

来源: Htaccess: add/remove trailing slash from URL