使用 .htaccess 进行 301 重定向
Make a 301 redirect with .htaccess
我想做重定向 301:
http://www.example.com/en/index.html
变为 http://www.example.com/en/
.
我该怎么做?
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
# remove index.html
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^(.*?)index\.html$ / [L,R=302,NC,NE]
较短的版本:
Redirect 301 /en/ /en/index.html
我想做重定向 301:
http://www.example.com/en/index.html
变为 http://www.example.com/en/
.
我该怎么做?
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
# remove index.html
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^(.*?)index\.html$ / [L,R=302,NC,NE]
较短的版本:
Redirect 301 /en/ /en/index.html