.htaccess 将example.com/index重定向到example.com

.htaccess 将example.com/index重定向到example.com,.htaccess,url,mod-rewrite,redirect,.htaccess,Url,Mod Rewrite,Redirect,由于一篇文章中的一个错误,我们的一个链接被添加为example.com/index,而不是example.com/index.html或简单的example.com。我们目前无法访问该文章,也不可能更改链接 我想添加一个.htaccess规则并重定向http://example.com/index至http://example.com。我找到了重定向子目录和文件的解决方案,但找不到只适用于http://example.com/index(而不是作为一个完整的子目录)其他一些解决方案也失败了。如果

由于一篇文章中的一个错误,我们的一个链接被添加为
example.com/index
,而不是
example.com/index.html
或简单的
example.com
。我们目前无法访问该文章,也不可能更改链接


我想添加一个
.htaccess
规则并重定向
http://example.com/index
http://example.com
。我找到了重定向子目录和文件的解决方案,但找不到只适用于
http://example.com/index
(而不是作为一个完整的子目录)其他一些解决方案也失败了。

如果请求
/index
错误,则应导致找不到页面。因此,请在.htaccess文件中查看这是如何工作的

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/index$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ / [R=301,L]

很好,很好。非常感谢。