markdown .HTACCESS FIXENS

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown .HTACCESS FIXENS相关的知识,希望对你有一定的参考价值。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
 
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType video/mp4 "access 1 month"
ExpiresByType video/webm "access 1 month"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
 
<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
 
  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>
#### Forward entire domain

```
RedirectMatch 301 ^(.*)$ http://www.valenciamorganhill.com/
```

#### Forward entire domain minus images
```
RewriteEngine on
RewriteCond %{REQUEST_URI}  !(\.png|\.jpg|\.gif|\.css|\.js|\.eot|\.svg|\.otf|\.woff|\.ttf)$
RewriteRule ^.+$ / [R=301,NC,L]
```

#### Forward entire domain alt.
```
RewriteEngine On
RewriteBase /
 
RewriteCond %{HTTP_HOST} ^lyonautumnchase.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.lyonautumnchase.com$
RewriteRule ^(.*)$ http://www.lyoncommunities.com/communities/welcome/autumn-chase [R=301,L]
```

#### Add SVG Support
```
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
```

#### Redirect non-www urls to www
```
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
```

 
#### Redirect non-www urls to www (alternate)
```
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule ^(.*) http://www.yoursite.com/$1 [QSA,L,R=301]
```

#### Redirect non-www urls to www (except a subdomain)
```
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(dev|www).yoursite.com$
RewriteRule ^(.*) http://www.yoursite.com/$1 [QSA,L,R=301]
```
 
#### Force https://
```
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
```

#### Force https & www at the same time
```
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
```

#### BLOCK ANALYTICS SPAM
```
RewriteEngine on
RewriteCond %{HTTP_REFERER} bestecommerceseo.com\.com [NC, OR]
RewriteCond %{HTTP_REFERER} wakeupseoconsultant\.com [NC, OR]
RewriteCond %{HTTP_REFERER} example-spam-website\.com [NC]
RewriteRule .* - [F]
```

以上是关于markdown .HTACCESS FIXENS的主要内容,如果未能解决你的问题,请参考以下文章

markdown HTACCESS - 但不适用于localhost

markdown HTACCESS - 但不适用于localhost

markdown 的.htaccess

markdown 压缩和更改到期时间#htaccess #performance

markdown 强制HTTPS #htaccess #https #security

markdown [www和https重定向]将所有文件重定向到https url和www域名#www #htaccess