Outils pour utilisateurs

Outils du site


webdev:redirections

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
webdev:redirections [19/07/2017 13:36]
dolo
webdev:redirections [25/04/2019 19:57] (Version actuelle)
dolo
Ligne 3: Ligne 3:
  
 **Redirection PHP :** **Redirection PHP :**
-<Code><?php +<Code linenums><?php 
 header('Location: '.get_bloginfo('url')); header('Location: '.get_bloginfo('url'));
 exit;</Code> exit;</Code>
Ligne 15: Ligne 15:
 Pour rediriger le site entier vers une nouvelle adresse : Pour rediriger le site entier vers une nouvelle adresse :
  
-<Code>Redirect permanent / http://nouveau-site.tld/</Code>+<Code linenums>Redirect permanent / http://nouveau-site.tld/</Code>
  
 Ex : Ex :
-<Code>+<Code linenums>
 # Redirections pour le référencement # Redirections pour le référencement
 <IfModule mod_alias.c> <IfModule mod_alias.c>
Ligne 27: Ligne 27:
  
 Pour changer un repertoire/fichier : Pour changer un repertoire/fichier :
-<Code>Redirect permanent /ancien_repertoire http://nouveau-site.tld/nouveau_repertoire+<Code linenums>Redirect permanent /ancien_repertoire http://nouveau-site.tld/nouveau_repertoire
 Redirect permanent /ancien_fichier.php http://site.tld/nouveau_fichier.php</Code> Redirect permanent /ancien_fichier.php http://site.tld/nouveau_fichier.php</Code>
 +
 +Global http to https :
 +<Code linenums>
 +# SSL/HTTPS
 +<IfModule mod_alias.c>
 + RewriteEngine On
 + RewriteCond %{HTTPS} !on
 + RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 +</IfModule>
 +</Code>
 +It's better to use a virtualhost to do that but that's the best way to do it on shared hosting : [[https://httpd.apache.org/docs/current/rewrite/avoid.html#redirect|Doc]] [[https://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https#answer-21798882|StackOverflow]]
  
  
Ligne 39: Ligne 50:
 It is better than using window.location.href =, because replace() does not put the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.\\ It is better than using window.location.href =, because replace() does not put the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.\\
 For example: For example:
-<Code:javascript>+<Code:javascript linenums>
 // similar behavior as an HTTP redirect // similar behavior as an HTTP redirect
 window.location.replace("http://stackoverflow.com"); window.location.replace("http://stackoverflow.com");
webdev/redirections.1500464207.txt.gz · Dernière modification: 19/07/2017 13:36 de dolo