22nd March 2017, 14:56
#1
1 out of 1 members found this post helpful.
Optimizarea vitezei / htaccess
Salutare Bogdan! Ma bucur sa vad tineri ambitiosi ca tine si care nu se dau guru in acest domeniu. De invatat avem toti, chiar si cei care sunt experti sau se considera experti. Daca nu este cu suparare, am sa iti dau cateva sfaturi pentru ca am putin timp liber si mai citesc cate ceva pe ici pe colo. Comunitatea asta are baieti capabili in domeniul SEO si ar trebui sa mai ceri ajutor din cand in cand. Stii, majoritatea uita cum a fost la inceputul carierei si este pacat sa nu ai respect fata de persoanele care sunt la inceput de drum, indiferent de domeniul in care activezi. Uite ce cred ca ar trebui sa faci la site-ul tau:
1. La instalarea unei teme WordPress, primul lucru care trebuie facut este sa redenumesti folderul temei in ceva care are legatura cu domeniul de activitate al site-ului. In cazul tau, nu ar trebui sa fie "zerif-lite", ci "web-design", sau "seo", etc. Daca vrei sa faci acum acest lucru, descarca tema in calculatorul tau, o redenumesti, urmezi pasii de la punctul 3, o incarci si o activezi.
2. Orice tema WordPress, are un fisier CSS, care se numeste style.css. Deschizi fisierul respectiv cu un editor de text si modifici datele de acolo. Nu este OK, sa apara "Theme Name: Zerif Lite"
3. Este foarte bine sa schimbi URL-ul catre folderul "wp-content", adica sa nu mai fie /wp-content/themes/, sa fie ceva de genul /fisiere-seo/themes/. Cum faci asta:
In structura WordPress (totul se face dupa instalarea WordPress si a temei), editezi fisierul wp-config.php si jos de tot adaugi asta:
/** Setează variabilele WordPress și fișierele incluse. */
define ('WP_CONTENT_FOLDERNAME', 'fisiere-seo');
define ('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME) ;
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_CONTENT_URL', WP_SITEURL . WP_CONTENT_FOLDERNAME);
require_once(ABSPATH . 'wp-settings.php');
header("Last-Modified: " . the_modified_date());
Dupa adaugarea codului respectiv, redenumesti fisierul wp-content in fisiere-seo, sau ce vrei tu dar sa fie acelasi nume ca in prima linie de cod, unde scrie fisiere-seo
4. Cresterea vitezei de incarcare in browser - poti testa site-ul inainte de adaugarea codului in .htaccess, cu PageSpeed Insights, de la Google. Editezi fisierul .htaccess si adaugi in partea de sus urmatorul cod de optimizare:
#Start Optimizare SEO on-page
<IfModule mod_expires.c>
FileETag none
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests
# in FF 3.6 (thx Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# RSS feed
ExpiresByType application/rss+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
<IfModule mod_deflate.c>
# force deflate for mangled headers
# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
</IfModule>
# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule !mod_filter.c>
# Legacy versions of Apache
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</IfModule>
#Expire Header
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 2 hours"
</FilesMatch>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png
<IfModule deflate_module>
<IfModule filter_module>
AddOutputFilterByType DEFLATE text/plain text/html
AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml
AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript
AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf
AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf
</IfModule>
</IfModule>
# Final Optimizare on-page
Ai aici cateva optiuni de optimizare standard, dar sunt mult mai multe. Daca ai nevoie de ajutor, poti cere aici fara jena. Cu siguranta se va gasi cineva sa te ajute. Trebuie sa fii constient ca website-ul tau de prezentare conteaza pentru client. daca tu oferi astfel de servicii si site-ul tau nu este OK, nu vei avea clienti.
Toata stima!