.htaccess文件是什么,如何创建.htaccess文件?

大话运营教研室 679 0

打开“记事本”文件,写入预备好的伪静态规则

例如,复制以下规则到记事本:

RewriteEngine on
RewriteCond %{http_host} ^yunyingwhy.com [NC]
RewriteRule ^(.*)$ www.yunyingwhy.com/$1 [L,R=301]

保存文件(具体如下):

文件名,填写:“.htaccess”

文件保存类型,选择“所以文件(*.*)

.htaccess中常用的两种代码:

第一种:

301方式设置网站首选域名:

RewriteEngine on
RewriteCond %{http_host} ^yunyingwhy.com [NC]
RewriteRule ^(.*)$ www.yunyingwhy.com/$1 [L,R=301]

第二种:

http跳转https

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yunyingwhycom/$1 [R,L]

.htaccess文件放到哪里?

.htaccess文件需要放到网站的根目录,上传文件前,要确认主机支持伪静态,并已经开启伪静态。

扩展内容:.htaccess怎样屏蔽ip,用.htaccess屏蔽IP方法

标签: URL链接优化

抱歉,评论功能暂时关闭!