◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
KANGLE环境APACHE环境.htaccess伪静态应用范例
以2kk8.com网站为例:整站跳转RewriteEngine onRewriteCond %{SERVER_PORT} !^443$RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]对某个目录做https强制跳转Rewrite...
总字数:1765以2kk8.com网站为例:
整站跳转
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
对某个目录做https强制跳转
RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
强制WWW域名301跳转
RewriteEngine on
RewriteCond %{HTTP_HOST} ^2kk8\.com [NC]
RewriteRule ^(.*)$ https://www.2kk8.com/$1
强制非WWW域名301跳转
RewriteEngine On
RewriteCond %{HTTP_HOST} !^2kk8.com$ [NC]
RewriteRule ^(.*)$ https//2kk8.com/$1 [L,R=301]
强制https地址转跳
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.2kk8.com/$1 [R,L]
阻止无用的蜘蛛爬虫获取
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (^$|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms) [NC]
RewriteRule ^(.*)$ - [F]
强制/斜杠结尾路径
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
取消/斜杠结尾
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]
将A页面301跳转到B页面
Redirect 301 /a.html https://www.2kk8.com/b.html
阻止某个IP访问
Order deny,allow
Allow from all
Deny from xxx.xxx.xxx.xxx
禁止图片盗链
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.+\.)?2kk8.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|bmp)$ - [NC,F,L]
禁止被其他网页套用
SetEnvIf Request_URI "/starry-night" allow_framing=true
Header set X-Frame-Options SAMEORIGIN env=!allow_framing
全部重定向到B网站
RewriteEngine on
RewriteRule ^(.*)$ https//www.2kk8.com/$1 [R=301,L]
2KK8.com
2KK8.com
这里的内容可以随意更改,在后台-主题配置中设置。