Jump to content

RedirectPermanent ne fonctionne pas


Recommended Posts

Bonjour,

j'essai de mettre en place une redirection sur des pages dans le .htaccess

voici le le contenu :

<IfModule mod_rewrite.c>
RewriteEngine on
  
RedirectPermanent /cannes/cq-9-close-quarter-3-brins-rod-CQ9275R-Carpe-10076.html$  https://www.carpvip.com/cannes/10076-4608-cq-9-close-quarter-3-brins-rod-Century.html

</IfModule>




# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# https://www.prestashop.com - https://www.prestashop.com/forums

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>


# Disable Multiviews
Options -Multiviews

RewriteEngine on

#Domain: www.carpvip.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# Images
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^www.carpvip.com$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]

# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>


AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/font-woff .woff
AddType font/woff2 .woff2
<IfModule mod_headers.c>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg)$">
		Header set Access-Control-Allow-Origin "*"
	</FilesMatch>

    <FilesMatch "\.pdf$">
      Header set Content-Disposition "Attachment"
      Header set X-Content-Type-Options "nosniff"
    </FilesMatch>
</IfModule>

<Files composer.lock>
    # Apache 2.2
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
    </IfModule>

    # Apache 2.4
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
</Files>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again

mais aucune redirection

Prestashop 1.7.8

Merci pour votre aide

Link to comment
Share on other sites

Pourquoi le $ ? Le redirectPermanent ne prend pas de variables

RedirectPermanent /cannes/cq-9-close-quarter-3-brins-rod-CQ9275R-Carpe-10076.html  https://www.carpvip.com/cannes/10076-4608-cq-9-close-quarter-3-brins-rod-Century.html

 

Link to comment
Share on other sites

merci pour votre aide.

je n'ai pas de module spécifique pour la redirection (essentiellement les modules de base de prestashop), et pas d'autres .htaccess, et celui ci est bien placé à la racine du site.

Ps: j'ai mis l'exemple pour une redirection, mais il y en a des centaines.

Link to comment
Share on other sites

les urls produits ne sont pas écrites de la même manière en 1.6 et 1.7

Et si ça: /cannes/cq-9-close-quarter-3-brins-rod-CQ9275R-Carpe-10076.html c'est une url 1.6, elle avait été modifiée car de base en 1.6 une url produit est de la forme:

id_produit-url_rewrite.html

Donc elle aurait dû être: 10076-cq-9-close-quarter-3-brins-rod-CQ9275R-Carpe.html

Link to comment
Share on other sites

je suis d'accord, mais sur 1.6 les urls ont été modifiés pour l'id soit à la fin de l'url

ce qui est confirmé par la search console

08/02/2022 08:59 https://www.carpvip.com/cannes/cq-9-close-quarter-3-brins-rod-cq9275r-Carpe-10076.html Introuvable (404)

je crois même que cela n'aurai pas vraiment d'importance car je pourrai mettre en place une redirection :

RedirectPermanent /cannes/toto-est-rigolo.html https://www.carpvip.com/cannes/10076-4608-cq-9-close-quarter-3-brins-rod-Century.html

et cela devrai fonctionner

 

Link to comment
Share on other sites

  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...