Apache 重定向到https并删除.html(.htaccess)
我想在我的网站上强制使用ssl,并删除我在本页URL末尾的文件扩展名,例如Apache 重定向到https并删除.html(.htaccess),apache,.htaccess,mod-rewrite,redirect,https,Apache,.htaccess,Mod Rewrite,Redirect,Https,我想在我的网站上强制使用ssl,并删除我在本页URL末尾的文件扩展名,例如http://www.site.com/image.html将被制作成https://www.site.com/image我已经有了重定向到https的部分,但是我想不出一种方法来删除我还有的第二部分不知道如何将此添加到.htaccess并使其工作。我一直使用的代码是 RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%
http://www.site.com/image.html
将被制作成https://www.site.com/image
我已经有了重定向到https的部分,但是我想不出一种方法来删除我还有的第二部分不知道如何将此添加到.htaccess并使其工作。我一直使用的代码是
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我非常感谢您的帮助和道歉,因为我是一个十足的新手。请将此添加到您的htaccess文件中:
RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\.html
RewriteRule ^ /%1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ /$1.html [L]
这是可行的,但是我的网站有一个文件索引,即.htaccess删除了.jpg。但是,如果我进入图像页面,我会在页面上得到一个文件索引,有没有办法避免这种情况,或者我会忘记删除文件扩展名?@AlanFletcher在具有
选项的/images/
目录中添加一个htaccess文件-索引中的
。