×

.htaccess 用法

hqy hqy 发表于2025-06-17 20:26:40 浏览7 评论0

抢沙发发表评论

<IfModule mod_rewrite.c>


RewriteEngine On

#  自动加www,自动跳转https

#RewriteCond %{HTTP_HOST} !^www\. [NC]

#RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]


# 不加www,自动跳转https

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


# 屏蔽掉?i=1 ?%1%2%3

RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC] 

RewriteRule ^(.*)$ /$1?%1%2%3 [R=301,L]

</IfModule>





<IfModule mod_rewrite.c>

RewriteEngine On


# 强制 HTTPS

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


# 针对 kinber.cn 强制加 www

RewriteCond %{HTTP_HOST} ^kinber\.cn$ [NC]

RewriteRule ^(.*)$ https://www.kinber.cn%{REQUEST_URI} [L,R=301]


# 如果不是文件或目录,路由到 index.php

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>


打赏

本文链接:https://www.kinber.cn/post/5164.html 转载需授权!

分享到:


推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

 您阅读本篇文章共花了: 

群贤毕至

访客