.htaccess服務器腳本是虛擬主機最常用的腳本之一,有了這個規(guī)則,就可以進行一系列的修改,滿足苛刻的SEOer們的需求,如果你不懂這些規(guī)則,找程序員幫你解決也可以。搞砸了可是服務器500錯誤,甚至FTP都登不進去。
這里秀站網(wǎng)秀站網(wǎng)經(jīng)過實踐,總結了全網(wǎng)最全經(jīng)測試有效的.htaccess規(guī)則。除了DedeCMS偽靜態(tài)規(guī)則外,其他問題都通用。
全面解決網(wǎng)站站內(nèi)SEO優(yōu)化問題:
①禁止蜘蛛抓取非主域名所有內(nèi)容,相關文章《徹底屏蔽已收錄的不需要的二級域名有效方法》;
②DedeCMS偽靜態(tài)規(guī)則,需要配合修改文件,相關文章《dedecms實現(xiàn)全站php偽靜態(tài)》;
③二級域名解析到二級目錄,相關文章《萬網(wǎng)利用.htaccess完美實現(xiàn)子域名跳轉(zhuǎn)到子目錄》;
④不帶www域名301跳轉(zhuǎn)到www的域名,相關文章《什么是301重定向怎么設置方法》;
⑤設置百度優(yōu)化建議max-age或expires,相關文章《解決百度頁面優(yōu)化建議未設置max-age或expires》;
⑥圖片、css、js壓縮Gzip,相關文章《萬網(wǎng)虛擬主機開啟Gzip壓縮教程測試有效》。
#非主域名訪問robots跳轉(zhuǎn)為wrobots(設置為禁止抓。,一定放最前面 RewriteEngine On RewriteCond %{HTTP_HOST} !^www.vi586.com [NC] RewriteRule ^robots.txt wrobots.txt [L] RewriteRule ^index\.(php|html|htm)$ http://www.vi586.com/ [R=301,L] #DedeCMS偽靜態(tài)規(guī)則 RewriteRule ^tags.html$ /tags.php RewriteRule ^tags/(.*).html$ /tags.php?/$1/ RewriteRule ^list-([0-9]+)\.html$ /plus/list.php?tid=$1 RewriteRule ^list-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 RewriteRule ^view-([0-9]+)\.html$ /plus/view.php?arcID=$1 RewriteRule ^view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2 RewriteRule ^index.html$ index.php #二級域名解析到二級目錄 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^zhan\.vi586\.com$ [NC] RewriteCond %{REQUEST_URI} !^/zhan/ RewriteRule ^(.*)$ zhan/$1?Rewrite [L,QSA] </IfModule> #不帶www域名301到帶www域名 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www.vi586.com [NC] RewriteRule ^(.*)$ http://www.vi586.com/$1 [L,R=301] </IfModule> #設置max-age或expires <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> #附件壓縮 <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/css text/javascript text/php text/png text/jpg text/xml text/plain image/gif image/jpeg image/png image/jpg application/x-javascript </IfModule>