Skip to content

Instantly share code, notes, and snippets.

@mikehins
Last active September 15, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehins/05b56787145e143fe5197004c8f7acad to your computer and use it in GitHub Desktop.
Save mikehins/05b56787145e143fe5197004c8f7acad to your computer and use it in GitHub Desktop.
Forcer les https dans wordpress et opencart

HTACCESS

<ifModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
</ifModule>

# Enlever les www (si nécéssaire pour le seo)
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]


# Forcer les www (si nécéssaire pour le seo)
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


# Force https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]

WORDPRESS

UPDATE wp_postmeta set meta_value = replace(meta_value, "http://domaine.com", "https://domaine.com");
UPDATE wp_posts set post_content = replace(post_content, "http://domaine.com", "https://domaine.com");
UPDATE wp_posts set pinged = replace(pinged, "http://domaine.com", "https://domaine.com");
UPDATE wp_options set option_value = replace(option_value, "http://domaine.com", "https://domaine.com");
UPDATE wp_comments set comment_author_url = replace(comment_author_url, "http://domaine.com", "https://domaine.com");
UPDATE wp_comments set comment_content = replace(comment_content, "http://domaine.com", "https://domaine.com");
UPDATE wp_posts set guid = replace(guid, "http://domaine.com", "https://domaine.com");

OPENCART

Dans l'admin

System -> Settings -> Edit

Ou en français

Système -> Paramètres -> Modifier
Onglet serveur -> Use SSL: Yes

CONFIGS /config.php et /admin/config.php

Modifier TOUT même les HTTP

// HTTP
define('HTTP_SERVER', 'https://domaine.com/admin/');
define('HTTP_CATALOG', 'https://domaine.com/');

// HTTPS
define('HTTPS_SERVER', 'https://domaine.com/admin/');
define('HTTPS_CATALOG', 'https://domaine.com/');
  • Faire le tour du site pour voir si le cadena reste toujours vert
  • Tester les formulaires
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment