htacess cho PHPFOX 3 cho SEO url

Nội dung file htacess mà tôi đã từng sử dụng:

Options -Indexes
Options +FollowSymLinks
Options -MultiViews

# 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
RewriteEngine On

# Modify Headers
<IfModule mod_headers.c>
# Cache files
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$">
  Header set Cache-Control "public"
  Header set Expires "Mon, 20 Apr 2015 20:00:00 GMT"
  Header unset Last-Modified
</FilesMatch>

# Cache JavaScript & CSS
<FilesMatch "\.(js|css)$">
  Header set Cache-Control "public"
  Header set Expires "Mon, 20 Apr 2015 20:00:00 GMT"
  Header unset Last-Modified
</FilesMatch>
</IfModule>
# Compress JavaScript & CSS
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
  SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
<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>
<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 3600 seconds"
  ExpiresByType text/html "access plus 3600 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>

<ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </filesMatch>
  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </filesMatch>
  <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </filesMatch>
  <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=216000, public, must-revalidate"
  </filesMatch>
  <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=1, private, must-revalidate"
  </filesMatch>
</ifModule>
<ifModule mod_headers.c>
  Header unset ETag
</ifModule>
FileETag None
RewriteEngine on
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType text/js A2592000
ExpiresByType application/js A2592000
# BEGIN COMPRESSION AND CACHING
<IfModule mod_deflate.c>
# Enable compression
AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript text/html text/plain text/xml image/x-icon

</IfModule>
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary Accept-Encoding
  </FilesMatch>
</IfModule>
### EXTRA PROTECTION FROM SOME HACKER ATTACKS BEGIN ### 

<IfModule mod_rewrite.c> 
Options +FollowSymLinks 
RewriteEngine On 
RewriteBase / 

# Block out any script trying to set a mosConfig value through the URL 
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] 

# Block out any script trying to base64_encode crap to send via URL 
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR] 

# Block out any script that includes a <script> tag in URL 
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR] 

# Block out any script trying to set a PHP GLOBALS variable via URL 
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR] 

# Block out any script trying to modify a _REQUEST variable via URL 
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2}) 

# Send all blocked request to homepage with 403 Forbidden error! 
RewriteRule ^(.*)$ index.php [F,L] 
</IfModule> 
### EXTRA PROTECTION FROM SOME HACKER ATTACKS END ###
### CDN SEO BEGIN ### 
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|ZIP)$">
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule .* - [E=CANONICAL:http://%{HTTP_HOST}%{REQUEST_URI},NE] 
RewriteCond %{HTTPS} =on 
RewriteRule .* - [E=CANONICAL:https://%{HTTP_HOST}%{REQUEST_URI},NE] 
</IfModule> 
<IfModule mod_headers.c> 
Header set Link "<%{CANONICAL}e>; rel=\"canonical\"" 
</IfModule> 
</FilesMatch> 
### CDN SEO END ### 

<IfModule mod_security.c>
  SecRuleEngine Off
  SecFilterInheritance Off
  SecFilterEngine Off
  SecFilterScanPOST Off
  SecRuleRemoveById 300015 3000016 3000017
</IfModule>

<FilesMatch "\.(php|htm|js|html?)$">
php_value memory_limit 128M
</FilesMatch>
####ETags
FileETag None

<IfModule mod_php5.c>
php_value memory_limit 128M
php_value post_max_size 20M
php_value upload_max_filesize 20M
php_flag output_buffering off
php_flag display_errors off
php_flag allow_url_fopen off
php_flag safe_mode off
php_flag sql.safe_mode off
php_value max_execution_time 30000000000000000000000000
php_value max_input_time 600000000000000000000000000
php_value session.gc_maxlifetime 150000000000000000000000000
</IfModule>

ErrorDocument 404 /404
ErrorDocument 403 https://wp.namls.name.vn
ErrorDocument 502 https://wp.namls.name.vn
ErrorDocument 503 https://wp.namls.name.vn
ErrorDocument 501 https://wp.namls.name.vn

# ALLOW USER BY IP
<Limit GET POST>
 order deny,allow
 deny from all
allow from 1.52.0.0/14
allow from 14.0.16.0/20
allow from 14.160.0.0/11
allow from 14.224.0.0/11
allow from 27.0.12.0/22
allow from 27.2.0.0/15
allow from 27.64.0.0/12
allow from 27.118.16.0/20
allow from 42.1.64.0/18
allow from 42.96.0.0/18
allow from 42.112.0.0/13
allow from 45.117.76.0/22
allow from 45.117.80.0/22
allow from 45.117.156.0/22
allow from 45.117.160.0/20
allow from 45.117.176.0/22
allow from 45.118.136.0/21
allow from 45.118.144.0/21
allow from 45.119.76.0/22
allow from 45.119.80.0/21
allow from 45.119.108.0/22
allow from 45.119.212.0/22
allow from 45.119.216.0/22
allow from 45.119.240.0/22
allow from 45.120.224.0/21
allow from 45.121.24.0/22
allow from 45.121.152.0/22
allow from 45.121.160.0/22
allow from 45.122.220.0/22
allow from 45.122.232.0/21
allow from 45.122.240.0/20
allow from 45.123.96.0/22
allow from 49.156.52.0/22
allow from 49.213.64.0/18
allow from 49.236.208.0/22
allow from 49.246.128.0/18
allow from 49.246.192.0/19
allow from 58.186.0.0/15
allow from 61.11.224.0/19
allow from 61.28.224.0/19
allow from 101.53.0.0/18
allow from 101.96.12.0/22
allow from 101.96.64.0/18
allow from 101.99.0.0/18
allow from 103.1.200.0/22
allow from 103.1.208.0/22
allow from 103.1.236.0/22
allow from 103.2.220.0/22
allow from 103.2.224.0/21
allow from 103.3.244.0/22
allow from 103.3.248.0/21
allow from 103.4.128.0/22
allow from 103.5.30.0/23
allow from 103.5.204.0/22
allow from 103.5.208.0/22
allow from 103.7.36.0/22
allow from 103.7.40.0/22
allow from 103.7.172.0/24
allow from 103.7.174.0/23
allow from 103.7.177.0/24
allow from 103.7.196.0/24
allow from 103.8.13.0/24
allow from 103.9.0.0/21
allow from 103.9.76.0/22
allow from 103.9.80.0/21
allow from 103.9.196.0/22
allow from 103.9.200.0/21
allow from 103.9.208.0/21
allow from 103.10.88.0/22
allow from 103.10.212.0/22
allow from 103.11.172.0/22
allow from 103.12.104.0/22
allow from 103.13.76.0/22
allow from 103.15.48.0/22
allow from 103.16.0.0/22
allow from 103.17.88.0/22
allow from 103.17.236.0/22
allow from 103.18.4.0/22
allow from 103.18.176.0/22
allow from 103.19.96.0/22
allow from 103.19.164.0/22
allow from 103.19.220.0/22
allow from 103.20.144.0/21
allow from 103.21.120.0/22
allow from 103.21.148.0/22
allow from 103.23.144.0/22
allow from 103.23.156.0/22
allow from 103.24.244.0/22
allow from 103.26.252.0/22
allow from 103.27.60.0/22
allow from 103.27.64.0/22
allow from 103.27.236.0/22
allow from 103.28.32.0/21
allow from 103.28.136.0/22
allow from 103.28.172.0/22
allow from 103.30.36.0/22
allow from 103.31.120.0/21
allow from 103.37.28.0/22
allow from 103.37.32.0/22
allow from 103.38.136.0/22
allow from 103.39.92.0/22
allow from 103.39.96.0/22
allow from 103.42.56.0/22
allow from 103.45.228.0/22
allow from 103.45.232.0/21
allow from 103.47.192.0/22
allow from 103.48.76.0/22
allow from 103.48.80.0/21
allow from 103.48.188.0/22
allow from 103.48.192.0/22
allow from 103.52.92.0/22
allow from 103.53.88.0/22
allow from 103.53.168.0/22
allow from 103.53.228.0/22
allow from 103.53.252.0/22
allow from 103.54.248.0/21
allow from 103.56.156.0/22
allow from 103.56.160.0/21
allow from 103.56.168.0/22
allow from 103.57.104.0/22
allow from 103.57.112.0/22
allow from 103.57.208.0/22
allow from 103.57.220.0/22
allow from 103.59.140.0/22
allow from 103.60.16.0/22
allow from 103.61.44.0/22
allow from 103.61.48.0/22
allow from 103.62.8.0/22
allow from 103.63.104.0/21
allow from 103.63.112.0/21
allow from 103.63.120.0/22
allow from 103.63.212.0/22
allow from 103.224.168.0/22
allow from 103.225.236.0/22
allow from 103.226.108.0/22
allow from 103.226.248.0/22
allow from 103.227.112.0/22
allow from 103.227.216.0/22
allow from 103.228.20.0/22
allow from 103.229.40.0/22
allow from 103.229.192.0/22
allow from 103.231.148.0/22
allow from 103.231.188.0/22
allow from 103.232.52.0/22
allow from 103.232.56.0/21
allow from 103.232.120.0/22
allow from 103.233.48.0/22
allow from 103.234.36.0/22
allow from 103.234.88.0/22
allow from 103.235.208.0/21
allow from 103.237.60.0/22
allow from 103.237.64.0/22
allow from 103.237.96.0/22
allow from 103.237.144.0/21
allow from 103.238.68.0/22
allow from 103.238.72.0/21
allow from 103.238.80.0/22
allow from 103.238.208.0/21
allow from 103.239.32.0/22
allow from 103.239.116.0/22
allow from 103.239.120.0/22
allow from 103.241.248.0/22
allow from 103.242.52.0/22
allow from 103.243.104.0/22
allow from 103.243.216.0/22
allow from 103.244.136.0/22
allow from 103.245.148.0/22
allow from 103.245.244.0/22
allow from 103.245.248.0/21
allow from 103.246.104.0/24
allow from 103.246.220.0/22
allow from 103.248.160.0/21
allow from 103.249.20.0/22
allow from 103.249.100.0/22
allow from 103.250.24.0/22
allow from 103.252.0.0/22
allow from 103.252.252.0/22
allow from 103.253.88.0/22
allow from 103.254.12.0/22
allow from 103.254.16.0/22
allow from 103.254.40.0/22
allow from 103.254.216.0/22
allow from 103.255.84.0/22
allow from 103.255.236.0/22
allow from 110.35.64.0/20
allow from 110.44.184.0/21
allow from 111.65.240.0/20
allow from 111.91.232.0/22
allow from 112.72.64.0/18
allow from 112.78.0.0/20
allow from 112.109.88.0/21
allow from 112.137.128.0/20
allow from 112.197.0.0/16
allow from 112.213.80.0/20
allow from 113.20.96.0/19
allow from 113.23.0.0/17
allow from 113.22.0.0/16
allow from 113.52.32.0/19
allow from 113.61.108.0/22
allow from 113.160.0.0/11
allow from 115.72.0.0/13
allow from 115.84.176.0/21
allow from 115.146.120.0/21
allow from 115.165.160.0/21
allow from 116.68.128.0/21
allow from 116.96.0.0/12
allow from 116.118.0.0/17
allow from 116.193.64.0/20
allow from 116.212.32.0/19
allow from 117.0.0.0/13
allow from 117.103.192.0/18
allow from 117.122.0.0/17
allow from 118.68.0.0/14
allow from 118.102.0.0/21
allow from 118.107.64.0/18
allow from 119.15.160.0/19
allow from 119.17.192.0/18
allow from 119.18.128.0/20
allow from 119.18.184.0/21
allow from 119.82.128.0/20
allow from 120.50.184.0/21
allow from 120.72.80.0/21
allow from 120.72.96.0/19
allow from 120.138.64.0/20
allow from 122.102.112.0/22
allow from 122.129.0.0/18
allow from 122.201.8.0/21
allow from 123.16.0.0/12
allow from 124.157.0.0/18
allow from 124.158.0.0/20
allow from 125.58.0.0/18
allow from 125.212.128.0/17
allow from 125.214.0.0/18
allow from 125.234.0.0/15
allow from 125.253.112.0/20
allow from 171.224.0.0/11
allow from 175.103.64.0/18
allow from 175.106.0.0/22
allow from 180.93.0.0/16
allow from 180.148.0.0/21
allow from 180.148.128.0/20
allow from 180.214.236.0/22
allow from 182.161.80.0/20
allow from 182.236.112.0/22
allow from 182.237.20.0/22
allow from 183.81.0.0/17
allow from 183.80.0.0/16
allow from 183.90.160.0/21
allow from 183.91.0.0/19
allow from 183.91.160.0/19
allow from 202.0.79.0/24
allow from 202.4.168.0/24
allow from 202.4.176.0/24
allow from 202.6.2.0/24
allow from 202.6.96.0/23
allow from 202.9.79.0/24
allow from 202.9.80.0/24
allow from 202.9.84.0/24
allow from 202.37.86.0/23
allow from 202.43.108.0/22
allow from 202.44.137.0/24
allow from 202.47.87.0/24
allow from 202.47.142.0/24
allow from 202.52.39.0/24
allow from 202.55.132.0/22
allow from 202.56.57.0/24
allow from 202.58.245.0/24
allow from 202.59.238.0/23
allow from 202.59.252.0/23
allow from 202.60.104.0/21
allow from 202.74.56.0/24
allow from 202.74.58.0/23
allow from 202.78.224.0/21
allow from 202.79.232.0/21
allow from 202.87.212.0/22
allow from 202.92.4.0/22
allow from 202.93.156.0/22
allow from 202.94.82.0/24
allow from 202.94.88.0/23
allow from 202.124.204.0/24
allow from 202.130.36.0/23
allow from 202.134.16.0/21
allow from 202.134.54.0/24
allow from 202.151.160.0/20
allow from 202.158.244.0/22
allow from 202.160.124.0/23
allow from 202.172.4.0/23
allow from 202.191.56.0/22
allow from 203.8.127.0/24
allow from 203.8.172.0/24
allow from 203.34.144.0/24
allow from 203.77.178.0/24
allow from 203.79.28.0/24
allow from 203.89.140.0/22
allow from 203.99.248.0/22
allow from 203.113.128.0/18
allow from 203.119.8.0/22
allow from 203.119.36.0/22
allow from 203.119.44.0/22
allow from 203.119.58.0/23
allow from 203.119.60.0/22
allow from 203.119.64.0/21
allow from 203.119.72.0/22
allow from 203.128.240.0/21
allow from 203.160.0.0/23
allow from 203.160.96.0/21
allow from 203.161.178.0/24
allow from 203.162.0.0/16
allow from 203.163.128.0/18
allow from 203.170.26.0/23
allow from 203.171.16.0/20
allow from 203.176.160.0/21
allow from 203.189.28.0/22
allow from 203.190.160.0/20
allow from 203.191.8.0/21
allow from 203.191.48.0/21
allow from 203.195.0.0/18
allow from 203.201.56.0/22
allow from 203.205.0.0/18
allow from 203.209.180.0/22
allow from 203.210.128.0/17
allow from 210.2.64.0/18
allow from 210.86.224.0/20
allow from 210.211.96.0/19
allow from 210.245.0.0/17
allow from 218.100.10.0/24
allow from 218.100.14.0/24
allow from 218.100.60.0/24
allow from 220.231.64.0/18
allow from 221.121.0.0/18
allow from 221.132.0.0/18
allow from 221.133.0.0/19
allow from 222.252.0.0/14
allow from 223.27.104.0/21

# ALLOW GOOGLEBOT
allow from 8.34.208.0/20
allow from 8.35.192.0/21
allow from 8.35.200.0/23
allow from 23.236.48.0/20
allow from 23.251.128.0/19
allow from 107.167.160.0/19
allow from 107.178.192.0/18
allow from 108.170.192.0/20
allow from 108.170.208.0/21
allow from 108.170.216.0/22
allow from 108.170.220.0/23
allow from 108.170.222.0/24
allow from 108.59.80.0/20
allow from 130.211.4.0/22
allow from 146.148.16.0/20
allow from 146.148.2.0/23
allow from 146.148.32.0/19
allow from 146.148.4.0/22
allow from 146.148.64.0/18
allow from 146.148.8.0/21
allow from 162.216.148.0/22
allow from 162.222.176.0/21
allow from 173.255.112.0/20
allow from 192.158.28.0/22
allow from 199.192.112.0/22
allow from 199.223.232.0/22
allow from 199.223.236.0/23
allow from 216.239.32.0/19 
allow from 64.233.160.0/19 
allow from 66.249.80.0/20 
allow from 72.14.192.0/18 
allow from 209.85.128.0/17 
allow from 66.102.0.0/20 
allow from 74.125.0.0/16 
allow from 64.18.0.0/20 
allow from 207.126.144.0/20 
allow from 173.194.0.0/16

#ALLOW FACEBOOK READ
allow from 204.15.20.0/22
allow from 69.63.176.0/20 
allow from 66.220.144.0/20 
allow from 66.220.144.0/21 
allow from 69.63.184.0/21 
allow from 69.63.176.0/21 
allow from 74.119.76.0/22 
allow from 69.171.255.0/24 
allow from 173.252.64.0/18 
allow from 69.171.224.0/19 
allow from 69.171.224.0/20 
allow from 103.4.96.0/22 
allow from 69.63.176.0/24 
allow from 173.252.64.0/19 
allow from 173.252.70.0/24 
allow from 31.13.64.0/18 
allow from 31.13.24.0/21 
allow from 66.220.152.0/21 
allow from 66.220.159.0/24 
allow from 69.171.239.0/24 
allow from 69.171.240.0/20 
allow from 31.13.64.0/19 
allow from 31.13.64.0/24 
allow from 31.13.65.0/24 
allow from 31.13.67.0/24 
allow from 31.13.68.0/24 
allow from 31.13.69.0/24 
allow from 31.13.70.0/24 
allow from 31.13.71.0/24 
allow from 31.13.72.0/24 
allow from 31.13.73.0/24 
allow from 31.13.74.0/24 
allow from 31.13.75.0/24 
allow from 31.13.76.0/24 
allow from 31.13.77.0/24 
allow from 31.13.96.0/19 
allow from 31.13.66.0/24 
allow from 173.252.96.0/19 
allow from 69.63.178.0/24 
allow from 31.13.78.0/24 
allow from 31.13.79.0/24 
allow from 31.13.80.0/24 
allow from 31.13.82.0/24 
allow from 31.13.83.0/24 
allow from 31.13.84.0/24 
allow from 31.13.85.0/24 
allow from 31.13.87.0/24 
allow from 31.13.88.0/24 
allow from 31.13.89.0/24 
allow from 31.13.90.0/24 
allow from 31.13.91.0/24 
allow from 31.13.92.0/24 
allow from 31.13.93.0/24 
allow from 31.13.94.0/24 
allow from 31.13.95.0/24 
allow from 69.171.253.0/24 
allow from 69.63.186.0/24 
allow from 204.15.20.0/22 
allow from 69.63.176.0/20 
allow from 69.63.176.0/21 
allow from 69.63.184.0/21 
allow from 66.220.144.0/20 
allow from 69.63.176.0/20

# ALLOW FUCK IP FOR VIETNAM
allow from 66.249.0.0/17
allow from 168.235.192.0/19
</Limit>

Với nội dung của file này nó sẽ tránh được BOT net ở mức vừa phải

Chúc thành công với web fox của bạn!

Bình luận về bài viết này