哆啦的时光机
以前的答案不会检查请求的路径是否是目录。如果请求的路径是目录(如原始问题所述),这里是不重写的完全重写条件:RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-d # is not directoryRewriteCond %{REQUEST_FILENAME}\.html -f # is an existing html fileRewriteRule ^(.*)$ $1.html # rewrite index to index.html要成为SEO友好并避免双重内容,重定向.html网址:# Redirects domain.com/file.html to domain.com/fileRewriteCond %{REQUEST_FILENAME} !-d # is not directoryRewriteCond %{REQUEST_FILENAME}\.html -f # is an existing html fileRewriteCond %{REQUEST_URI} ^(.+)\.html$ # request URI ends with .htmlRewriteRule (.*)\.html$ /$1 [R=301,L] # redirect from index.html to index