日期:
来源:Linux公社收集编辑:聆听世界的鱼
点击上方蓝字 ● 关注Linux公社
RewriteEngine onRewriteCond %{HTTP_HOST} !^www\.RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine OnRewriteCond %{HTTPS} offRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Order deny,allowDeny from 123.45.67.89
AuthType BasicAuthName "Restricted Area"AuthUserFile /path/to/password/fileRequire valid-user
RewriteEngine onRewriteCond %{HTTP_REFERER} !^$RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.com/.*$ [NC]RewriteRule \.(gif|jpg|jpeg|png|bmp)$ - [F]
ErrorDocument 404 /errors/404.html
<IfModule mod_deflate.c>AddOutputFilterByType DEFLATE text/plainAddOutputFilterByType DEFLATE text/htmlAddOutputFilterByType DEFLATE text/xmlAddOutputFilterByType DEFLATE text/cssAddOutputFilterByType DEFLATE application/xmlAddOutputFilterByType DEFLATE application/xhtml+xmlAddOutputFilterByType DEFLATE application/rss+xmlAddOutputFilterByType DEFLATE application/javascriptAddOutputFilterByType DEFLATE application/x-javascript</IfModule>
Options -Indexes
<IfModule mod_expires.c>ExpiresActive OnExpiresByType text/css "access plus 1 week"ExpiresByType text/javascript "access plus 1 week"ExpiresByType application/javascript "access plus 1 week"ExpiresByType image/gif "access plus 1 month"ExpiresByType image/png "access plus 1 month"ExpiresByType image/jpeg "access plus 1 month"ExpiresByType image/x-icon "access plus 1 year"</IfModule>
Redirect 301 /old-page.html https://www.linuxmi.com/new-page.html
<FilesMatch "\.(php|pl|py|jsp|asp|sh|cgi)$">Order allow,denyDeny from all</FilesMatch>
Options +IncludesAddType text/html .shtmlAddHandler server-parsed .shtml
DirectoryIndex index.php index.html
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|sql)$">Order deny,allowDeny from all</FilesMatch>
php_value memory_limit 256Mphp_value upload_max_filesize 64Mphp_value error_reporting E_ALL
RewriteEngine OnRewriteRule ^blog/([^/\.]+)/?$ blog.php?id=$1 [L]
Order deny,allowDeny from allAllow from 123.45.67
RewriteEngine OnRewriteCond %{HTTPS} offRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
ErrorDocument 404 /404.htmlErrorDocument 500 /500.html
ServerSignature Off
RewriteEngine OnRewriteCond %{HTTP_USER_AGENT} badbot1 [NC,OR]RewriteCond %{HTTP_USER_AGENT} badbot2 [NC,OR]RewriteCond %{HTTP_USER_AGENT} badbot3RewriteRule ^(.*)$ - [F,L]
链接:https://www.linuxmi.com/htaccess-20-real-world-examples.html
关注我们 长按或扫描下面二维码关注 Linux公社
关注 Linux公社,添加“ 星标 ”
每天 获取 技术干货,让我们一起成长
合作联系:root@linuxidc.net