apache_conf 强大的.htaccess片段,需要在最顶层使用RewriteEngine On

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf 强大的.htaccess片段,需要在最顶层使用RewriteEngine On相关的知识,希望对你有一定的参考价值。

# Default force to HTTPS for all traffic
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Force SSL / HTTPS Redirection v2
Options +FollowSymLinks
Options -Indexes
Options -MultiViews
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Force non-www:
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

# Deny and than redirect every IP that is not on the whitelist
# Protect a specific directy by creating another .htaccess file ^ _ ^
order deny,allow
allow from 192.168.1.420
deny from all

ErrorDocument 403 https://redirect-visitor.com

# Prevent viewing of .htaccess file.
<Files .htaccess>
order allow,deny
deny from all
</Files>

# Optimize website, enable compression gzip
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

以上是关于apache_conf 强大的.htaccess片段,需要在最顶层使用RewriteEngine On的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf 通过.htaccess(主.htaccess)保护wordpress网站

apache_conf [linux:.htaccess] apache的htaccess说明。 #linux #apache

apache_conf htaccess的

apache_conf [htaccess的]

apache_conf 的.htaccess

apache_conf 的.htaccess