Adaugare trailing slash folosind .htaccess


(Cosmin) #1

Salutare,

Am o problema cu un .htaccess pentru care am fost solicitat sa adaug automat trailing slash pentru toate link-urile site-ului.

FIsierul arata acum astfel:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_URI} !^/proiectetip
RewriteRule ^search/$ search.php [QSA,L]
RewriteRule ^(.*)/(.*)-([0-9]+)/(.*)-([0-9]+)/([0-9]+)/$ index.php?section_permalink=$1&content_permalink=$2&content_id=$3&subcontent_permalink=$4&subcontent_id=$5&image_id=$6 [QSA,L]
RewriteRule ^(.*)/(.*)-([0-9]+)/(.*)-([0-9]+)/$ index.php?section_permalink=$1&content_permalink=$2&content_id=$3&subcontent_permalink=$4&subcontent_id=$5 [QSA,L]
RewriteRule ^(.*)/(.*)-([0-9]+)/$ index.php?section_permalink=$1&content_permalink=$2&content_id=$3 [QSA,L]
RewriteRule ^(.*)/$ index.php?section_permalink=$1 [QSA,L]

Nu sunt foarte priceput in scrierea acestor reguli, am incercat diverse abordari, insa fara succes.

Practic, pe langa regulile de la 6-12, ce ar trebui sa se intample ar fi:

  • Redirect catre versiunea cu WWW
  • Redirect catre versiunea cu HTTPS
  • Adaugare trailing slash