Certificats SSL - Certificat ssl et redirection 301
... / Certificat ssl et redirec...
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Frage

Certificat ssl et redirection 301

Von
c2d75f1f20a77183ea4b
Erstellungsdatum 2020-09-04 04:52:18 (edited on 2024-09-04 10:50:11) in Certificats SSL

Bonjour
J ai créé un fichier htaccess avec une redirection 301 pour afficher mon site en https,
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://wwwmonsite.fr/$1 [R=301,L]
Pas de problème le site s'affiche bien avec https, par contre pour le Référencement je veux refaire une redirection serveur sur le fichier **index.html** vers **pageexemple.html**
j ai inséré code php dans mon fichier **pageexemple.html** mais j ai une page blanche qui s affiche
header("Status: 301 Moved Permanently", false, 301);
header("Location: https://www.monsite.fr/pageexemple.html");
exit();
?>
Conflit de redirection 301 car sans la ligne rewriterule fichier htaccess la page s'affiche correctement mais sans https ou y a t il une autre solution pour afficher https sans passer par fichier htaccess
Merci pour votre aide


4 Antworten ( Latest reply on 2020-09-06 17:08:53 Von
c2d75f1f20a77183ea4b
)

pourquoi ne pas tout faire avec le `.htaccess`?
quel site à tester?

Bonjour
En effet on peut modifier fichier access , je croyais que cela nuisait au référencement
donc
RedirectPermanent /index.html https://www.monsite.fr/pageexemple.html
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
mais j aurais bien aimé comprendre pourquoi (culture personnel) fichier index html avec code php rentre en conflit avec fichier htaccess quel etait erreur

```text > je croyais que cela nuisait au référencement

non, le .htaccess n'est qu'un moyen rapide de le faire

tu oublies la redirection sur sous-domaine
```text
RedirectPermanent /index.html https://www.monsite.fr/pageexemple.html

RewriteEngine On

## no-www -> www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]

## http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]
```

ou
```text
## pageexemple.html en premier devient prioritaire pour le listage du dossier
DirectoryIndex pageexemple.html index.php index.html


RewriteEngine On

## no-www -> www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]

## http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]
``` ```


## pageexemple.html en premier devient prioritaire pour le listage du dossier
DirectoryIndex pageexemple.html index.php index.html


RewriteEngine On

## no-www -> www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]

## http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,QSA]


ok Merci