我在.htaccess脚本中找到了几篇关于如何使用mod重写删除文件扩展名的文章,但理想情况下我要删除文件扩展名和名称。
例如,wearedeja.com/index.html应显示wearedeja.com
显然像apple.com这样的网站可以做到这一点,所以即使复杂也必须这样。
我已经在堆栈溢出和关闭时进行搜索和搜索,并且似乎找不到删除扩展程序。非常感谢任何帮助。
答案 0 :(得分:1)
尝试:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+(.*?/?)index\.(php|html?)
RewriteRule ^(.*)index\.(php|html?)$ /$1 [L,R=301]
DirectoryIndex index.html index.php
答案 1 :(得分:1)
看到您的服务器使用nginx作为服务器,而不是apache:
我认为这应该有效:
index index.html index.php;
location / {
rewrite ^/(.*)index\.(php|html?)$ /$1 redirect;
}
应该添加到你的nginx配置