mildoriel Posted September 27, 2018 Share Posted September 27, 2018 Deoarece am pus https si doresc sa folosesc musai si www, doresc redirectionarea tuturor intrarilor, din prima, spre https://www. Insa redirectionarea se face, cel mai adesea, cam asa http://exemplu.ro -> http://www.exemplu.ro -> https:///www/exemplu.ro Deci sunt cel putin 2 redirectionari. Intrebarea mea este daca se poate pune reguli si conditii in htaccess astfel incat sa fie o singura redirectionare http://exemplu.ro -> https://www.exemplu.ro. Deoarece am cautat si incercat ore pe internet fara rezultat si nu sunt bun decat la a face copy-paste in htaccess, ii rog pe cei care se pricep sa ne lase si noua niste linii de cod functionale pe care sa le copiem si sa le punem in htaccess. Cei care vor sa evite penalizari google va vor multumim cu siguranta. Folosesc prestashop 1.7.4.2, apache 2.4.6, php 7.2.8 Link to comment Share on other sites More sharing options...
Rhobur Posted September 28, 2018 Share Posted September 28, 2018 Incearca asta: RewriteCond %{HTTPS} !on [OR] RewriteCond %{HTTP_HOST} !^www\. RewriteRule (.*) https://www.example.com%{REQUEST_URI} [L,R=301] Link to comment Share on other sites More sharing options...
mildoriel Posted September 28, 2018 Author Share Posted September 28, 2018 (edited) Mie nu imi merge, dar poate nu e vina codului ci a fisierului meu htaccess caruia i-a inceput sa ii creasca diferite blocuri de coduri. Pentru a elimina orice urma de dubiu, postez intreg fisierul, codul tau e pus cu # deoarece nu merge dar l-am lasat asa pt eventuale rectificari ulterioare. Acum, in lumina unor evitari de penalizari gtmetrix / pagespeed insight, cum ar trebui sa arate un SUPER-OPTIMIZAT htaccess care sa evite si redirectionarile cerute mai sus. <IfModule mod_rewrite.c> <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> RewriteEngine on RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule . - [E=HTTP_AUTHORIZATION:%1] RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+) [NC] RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NE] #Domain: www.exemplu.ro RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api$ api/ [L] RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] ....... Edited October 16, 2018 by mildoriel (see edit history) Link to comment Share on other sites More sharing options...
singfa Posted October 14, 2018 Share Posted October 14, 2018 (edited) Incearca varianta asta: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\.exemplu\.ro$ [NC] RewriteRule ^(.*)$ https://www.exemplu.ro/$1 [L,R=301] sau RewriteEngine on # Force www: from http://exemplu.ro/ RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Force SSL: From http://exemplu.ro/ RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE] Bineinteles, celelate linii de cod care se refera la aceste lucruri trebuie sterse. Inainte de asta fa-ti un backup la fisierul original. Edited October 14, 2018 by singfa (see edit history) Link to comment Share on other sites More sharing options...
mildoriel Posted October 16, 2018 Author Share Posted October 16, 2018 (edited) Multumesc de variante. Am incercat si aceste 2 variante, insa nu functioneaza pe sistemul meu cu: prestashop 1.7.4.2, apache 2.4.6, php 7.2.8, 7.2.10. Ceea ce lucreaza la mine este acesta varianta de care sunt super multumit: RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+) [NC] RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NE] Sfatui pe cei care au acces la htacces si lucreaza cu https - www, sa incerce minimizarea redirectionarilor, este o chestie pe care google o va aprecia. Mai mult ca sigur ca depinde de apache, nginx si ce mai aveti pe-acolo. Insa, testati de mai multe ori cu gtmetrix sau pagespeed insight toate variantele prezentate in acest topic, notati-le si faceti comparatii. Trebuie sa va uitati la rezultatele de "redirect", sa fie cat mai putine redirectionari. Asteptam si alte pareri de cum poate fi imbunatatit htaccesul. Edited October 16, 2018 by mildoriel (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now