Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 写入htaccess以隐藏html文件扩展名+;使http转到https+;让xyz.com转到www.xyz.com_.htaccess - Fatal编程技术网

.htaccess 写入htaccess以隐藏html文件扩展名+;使http转到https+;让xyz.com转到www.xyz.com

.htaccess 写入htaccess以隐藏html文件扩展名+;使http转到https+;让xyz.com转到www.xyz.com,.htaccess,.htaccess,我在htaccess文件中有以下代码 RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.domain-name.com/$1 [R,L] 我不知道有关htaccess文件的任何信息,但这似乎可以执行以下操作: •使domain-name.com转到www.domain-name.com 及 •前往 所以一切都会朝着我想要的方向发展 但是,如何隐藏.html文件的结尾?所以domain-

我在htaccess文件中有以下代码

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.domain-name.com/$1 [R,L]
我不知道有关htaccess文件的任何信息,但这似乎可以执行以下操作:

•使domain-name.com转到www.domain-name.com

•前往

所以一切都会朝着我想要的方向发展

但是,如何隐藏.html文件的结尾?所以domain-name.com/about.html变成了domain-name/about

我发现了以下代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

但是不知道如何组合这两位代码?

您可以在Apache配置或站点root.htaccess中使用以下规则:

RewriteEngine On

# add www and turn on https in same rule
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

## hide .html extension
# To externally redirect /file.html to /file
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,NE,L]

# To internally rewrite /file to /file.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

非常感谢。在我的html中,当链接到“关于”页面时,我应该链接到还是?最好有
,但是这些规则会将旧的html链接重定向到没有
的页面。html
这会降低网页的加载速度吗?我想知道,当页面加载时,是否会出现闪烁,即使它们正在重定向页面,速度也会变慢?所有这些规则都与页面加载速度无关。