Hébergements Web - Problème htaccess suite MAJ apache 2.2->2.4
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

Problème htaccess suite MAJ apache 2.2->2.4

Von
RaffiM
Erstellungsdatum 2017-12-03 12:27:36 (edited on 2024-09-04 12:34:52) in Hébergements Web

Bonjour,

Je suis total perdu. Je lutte comme un âne depuis 48h, et je m'aperçois seulement ce matin du message OVH qui indique dans le manager qu'il y a un risque autour du fichier .htaccess.

J'ai une configuration simple mais tordu.
Mon site comporte :
1. un wordpress installé dans "/blog/" (fonctionne)
2. un module à part (rien à voir avec wordpress) dans "/portfolio/" (**fonctionne PAS**)
3. des fichiers .html en vrac à la racine (fonctionne)
4. et particularité, ma homepage est géré par wordpress même si elle est d'un niveau supérieur dans l'arboresence "/". (fonctionne)

Du coup, quand çà fonctionnait (avant quoi) j'avais réussi à l'aide d'un développeur à paramétrer correctement mes fichiers htaccess principaux au nombre de 3.

1. home "/.htaccess"
2. blog "/blog/.htaccess"
3. portfolio "/portfolio/.htaccess".

/.htaccess
PS : mon .ovfconfig est paramétrer pour php version 7.

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

ErrorDocument 404 https://www.monsite.fr/portfolio/

RedirectPermanent /index.html /index.php
RedirectPermanent /Album-Photo-Mariage /portfolio

/blog/.htaccess



order deny,allow
deny from all
allow from 2a01:cb00:6b4:5600:cfd:976c:f080:9ded
allow from 178.33.103.78


Require ip 2a01:cb00:6b4:5600:cfd:976c:f080:9ded 178.33.103.78


# END GOTMLS Patch to Block XMLRPC Access
SetEnv PHP_VER 5_TEST
# BEGIN rlrssslReallySimpleSSL rsssl_version[2.5.20]

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# END rlrssslReallySimpleSSL
# BEGIN WordPress

RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

# BEGIN Protect XML-RPC

Order Deny,Allow
Deny from all

# END Protect XML-RPC
# END WordPress

/portfolio/.htaccess

# X3 REQUIRED
# Below rewrite rules are strictly required by X3 for pages to work properly.
# ---------------------------------------------------------------------------

# RewriteEngine enabled
RewriteEngine o
# custom rules start
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# custom rules end
# RewriteBase (required for some hosts)
# If X3 is installed in root: RewriteBase /
# If X3 is installed in sub-directory x3: RewriteBase /x3
# RewriteBase /
# Rewrite any calls to html|json|xml|atom|rss if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+)\.(html|json|xml|atom|rss)$ $1/ [L]
# Rewrite any calls to /render to the X3 image resizer
RewriteCond %{REQUEST_URI} render/
RewriteRule ^render/. app/parsers/slir/ [L]
# Rewrite routes to X3 application index.php if they are non-existent files/dirs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?/$1/ [L,QSA]
#RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

# ---------------------------------------------------------------------------
# OPTIONAL X3 APACHE SERVER CONFIG (if you have your own Apache server)
# https://gist.github.com/mjau-mjau/f4acd76bef4c1d33fba22913a9ff488e
# https://gist.github.com/mjau-mjau/b8fe3d3719bc400528945b194706e6f5
# ---------------------------------------------------------------------------
# X3 OPTIONAL
# Below rules are optional, but included by default for best practice.
# Many of the rules below should already be default from your Apache server.
# https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess
# --------------------------------------------------------------------------

# Add a trailing slash to directories (/dir -> /dir/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.|\?)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]
# Set HTTP_MOD_REWRITE flag for X3 diagnostics, used to detect mod_rewrite

SetEnv HTTP_MOD_REWRITE On

# Allow basic authentication in X3 for servers running PHP as FastCGI
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Prevent X3 Diagnostics from showing server information
#
# SetEnv X3_HIDE_DIAGNOSTICS On
#
# Block directory listing.
# This should already be default on your server, and is disabled here because it creates errors on some servers.
#
# Options -Indexes
#
# Serve resources labeled as text/html with media type charset set to UTF-8 (unicode).
AddDefaultCharset utf-8
# Serve resources with the proper media types (MIME types).

AddType application/json json
AddType application/javascript js
AddType image/svg+xml svg
AddType image/webp webp
AddType video/mp4 mp4
# Serve some extensions with media type charset set to UTF-8 (unicode).
AddCharset utf-8 .css .js .xml .json

# Compress output (GZIP).

AddOutputFilterByType DEFLATE application/javascript \
application/json \
application/xml \
image/svg+xml \
text/css \
text/html \
text/xml

# Remove ETags as resources are sent with far-future expires headers.

Header unset ETag

FileETag None
# Agressive cache expires headers

ExpiresActive on
ExpiresDefault "access plus 10 years"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/xml "access plus 3600 seconds"
ExpiresByType application/xml "access plus 3600 seconds"



Par ailleurs, comme je n'avais pas identifié l'éventualité de cette cause hier, j'ai demandé un snap de mon FTP/SQL à une semaine. La base SQL a été restauré dans la foulée, pour le FTP, j'attends depuis 14h et la tâche est toujours en cours dans le manager (et bizarre mon espace utilisé est passé de 90go à 250go) et j'attends toujours, je me demande si c'est normal (+ quand je me connecte en ftp au snap3 j'ai l'impression d'y trouver la même chose que mon contenu quotidien et plus le contenu de la semaine dernière).


18 Antworten ( Latest reply on 2017-12-04 08:18:35 Von
Gaston_Phone
)


mon .ovfconfig est paramétrer pour php version 7.


c'est possible d'avoir le contenu de ce fichier ?

Oui bien entendu

/.ovhconfig

app.engine=php
app.engine.version=7.0
http.firewall=none
environment=production

il faudrait ajouter à la dernière ligne :

container.image=stable

Sinon, quel est le message d'erreur lors de l'accès au site ?


container.image=stable


C'est fait.


La home et le blog fonctionne, mais quand je tente d'afficher /portfolio j'ai une erreur 500

` Cette page ne fonctionne pas`


Impossible de traiter cette demande via www.monsite.fr à l'heure actuelle.
HTTP ERROR 500


<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript \
application/json \
application/xml \
image/svg+xml \
text/css \
text/html \
text/xml
</IfModule>


et en supprimant ce bloc ?

NB : si le but est que le site et les ss domaines ne soient accessible que via https, il est aussi possible d'ajouter cette directive au .htaccess
Header set Strict-Transport-Security "max-age=160600; includeSubDomains; preload"

C'est fait, sans amélioration :(
J'ai passé en # le bloc mentionné.
ps : aucun sous-domaine pour ce domaine.

il faudrait alors désactiver bloc par bloc le contenu du .htaccess dans /portfolio/.htaccess
et voir ce qui cloche ..

Le conseil est de testé le retrait des blocs, mais un par un (c'est à dire que si je constate que çà marche pas, je replace les lignes précédemment retirées ?)

J'ai essayé en retirant le htaccess çà aurait du marché sans ??? (non ?)

J'ai tenté tout les blocs un par un sans succès :(

Je sais pas si çà peut aider, mais j'ai pas de problème pour accéder à l'admin /porfolio/admindirectory/

Bon ... une bonne nouvelle : en forçant la mise à jour de mon module /portfolio/ l'apache 2.4 semble avoir corrigé mon problème.

Par contre dégouté, j'ai demandé un snap ovh hier, et quand çà va passer çà va tout m'écraser ... du coup j'attends .

Normal d'attendre genre 14/15h et ne toujours rien avoir sur la restauration qui reste mentionnée comme étant en cours dans le manager OVH ?

Si tu ne vois aucun changement même avec le .htaccess retiré c'est probablement que ton navigateur garde la page en cache ..

Je viens de vider le cache.

Me reste un souci : lorsque j'affiche mon site / la rewrite semble pointer sur /index.php !
Comment faire pour que le navigateur reste sur /

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

ErrorDocument 404 https://www.1mariage.fr/portfolio/mariage.fr/portfolio/

RedirectPermanent /index.html /index.php
RedirectPermanent /Album-Photo-Mariage /portfolio


Si je change :
` RedirectPermanent /index.html /index.php`
pour
` RedirectPermanent /index.php /`

çà marche plus !

```text # ---------------------------------------------------------------------------
# X3 REQUIRED
# Below rewrite rules are strictly required by X3 for pages to work properly.
# Add custom rules inside "# custom rules start" and "# custom rules end" tags.
# ---------------------------------------------------------------------------



# RewriteEngine enabled
RewriteEngine on

# RewriteBase (required for some hosts)
# If X3 is installed in root: RewriteBase /
# If X3 is installed in sub-directory x3: RewriteBase /x3
# RewriteBase /

# Rewrite any calls to html|json|xml|atom|rss if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+)\.(html|json|xml|atom|rss)$ $1/ [L]

# Rewrite any calls to /render to the X3 image resizer
RewriteCond %{REQUEST_URI} render/
RewriteRule ^render/. app/parsers/slir/ [L]

# Rewrite routes to X3 application index.php if they are non-existent files/dirs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?/$1/ [L,QSA]
#RewriteRule ^(.*)$ index.php?/$1 [L,QSA]



# ---------------------------------------------------------------------------
# OPTIONAL X3 APACHE SERVER CONFIG (if you have your own Apache server)
# https://gist.github.com/mjau-mjau/f4acd76bef4c1d33fba22913a9ff488e
# https://gist.github.com/mjau-mjau/b8fe3d3719bc400528945b194706e6f5
# ---------------------------------------------------------------------------
# X3 OPTIONAL
# Below rules are optional, but included by default for best practice.
# Many of the rules below should already be default from your Apache server.
# https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess
# --------------------------------------------------------------------------



# Add a trailing slash to directories (/dir -> /dir/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.|\?)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]

# Set HTTP_MOD_REWRITE flag for X3 diagnostics, used to detect mod_rewrite

SetEnv HTTP_MOD_REWRITE On


# Allow basic authentication in X3 for servers running PHP as FastCGI
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


# Prevent X3 Diagnostics from showing server information
#
# SetEnv X3_HIDE_DIAGNOSTICS On
#

# Block directory listing.
# This should already be default on your server, and is disabled here because it creates errors on some servers.
#
# Options -Indexes
#

# Serve resources labeled as text/html with media type charset set to UTF-8 (unicode).
AddDefaultCharset utf-8

# Serve resources with the proper media types (MIME types).

AddType application/json json
AddType application/javascript js
AddType image/svg+xml svg
AddType image/webp webp
AddType video/mp4 mp4

# Serve some extensions with media type charset set to UTF-8 (unicode).
AddCharset utf-8 .css .js .xml .json


# Compress output (GZIP).

AddOutputFilterByType DEFLATE application/javascript \
application/json \
application/xml \
image/svg+xml \
text/css \
text/html \
text/xml


# Remove ETags as resources are sent with far-future expires headers.

Header unset ETag

FileETag None

# Agressive cache expires headers

ExpiresActive on
ExpiresDefault "access plus 10 years"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/xml "access plus 3600 seconds"
ExpiresByType application/xml "access plus 3600 seconds"


Voici à quoi ressemble mon /portfolio/.htaccess qui cache peut être le problème de /index.php vs / ```

```text pour ton problème, je ne sais pas, mais tu as un problème avec des ExpiresDefault et ExpiresByType

il te manque la durée ...
tu devrais avoir des choses du genre

`ExpiresDefault "access plus 1 month"`
`ExpiresByType text/xml "access plus 2 hours"`

source : https://httpd.apache.org/docs/2.4/fr/mod/mod_expires.html ```

çà marche !

j'ai retiré :

`RedirectPermanent /index.html /index.php`

et j'ai ajouté

RewriteEngine On
RewriteRule ^index\.php$ / [R=301,L]
RewriteRule ^(.*)/index\.php$ /$1/ [R=301,L]


Je regarderai le ExpiresDefault, mais tu sais ... j'y connais pas grand chose :)

Quel caca!

Supprime seulement les fichiers **_/www/index.html_** et **_/www/index.htm_**

les fichiers n'existent index.htm* pas et maintenant que tout marche j'ose plus trop touché :)


les fichiers n'existent index.htm* pas et maintenant que tout marche j'ose plus trop touché :)

Suite du caca : Ton site est-il dans le dossier **_/www/index.php/_** ?

Domaine ? ? ?