The url of the product categories end in /
But the products themselves do not, so when adding this rule:
# si no existe un archivo que coincida con la solicitud...
RewriteCond %{REQUEST_FILENAME} !-f
# y si no termina con una barra, redireccionar a la misma dirección pero con la barra
RewriteRule ^(.*[^/]$) $1/ [R,QSA,L]
it works for the categories, but I get 404 error with the rest of the URLs.
That is to say
-
https://www.dominio.com/coches
redirects to -
https://www.dominio.com/coches/
(perfect)
But the other URLs, such as:
-
https://www.dominio.com/producto/ford-fiesta-5p-rojo
redirects to -
https://www.dominio.com/producto/ford-fiesta-5p-rojo/
( error 404 )
How can I solve this?
I have seen that there is a directory /producto/
in this type of url and maybe an if or something could be done .. Anyway I can not assure that all the url types that give this problem have that directory product or other .
My .htaccess is this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
DirectoryIndex imagen.php index.php index.html index.htm
# Forzar para que funcione con el https
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.dominio.com/$1 [R,L]
# Forzar que no trabaje en .es y lo convierta todo a .com . Lo tuve que asteriscar una vez con Tomas.
RewriteCond %{HTTP_HOST} ^www\.dominio\.es$ [NC]
RewriteRule ^(.*)$ https://www.dominio.com/$1 [L,R=301,NE]
#Nacho 07/07/2017
#Forzar que se redireccionen las url con www y se haga un 301 cuando se acceda sin www
RewriteCond %{HTTP_HOST} !^www.dominio.com [NC]
RewriteRule ^(.*)$ http://www.dominio.com/$1 [R=301,L]
#08/09/2017 NACHO
Redirect 301 https://www.dominio.com/imagen.php?clave=wsgw_dominio_verGama&pCodigo=10 https://www.dominio.com/estanteria-convencional.html
Redirect 301 https://www.dominio.com/imagen.php?clave=wsgw_dominio_verGama&pCodigo=17 https://www.dominio.com/estanterias-ligeras.html
#08/09/2017
# GENERICAS
RewriteRule ^registro.html$ /imagen.php?clave=wsgw_registro [QSA,L]
RewriteRule ^registro/$ /imagen.php?clave=wsgw_registro [QSA,L]
RewriteRule ^empresa/(.*)$ /imagen.php?id_pagina=1 [QSA,L]
RewriteRule ^noticias/(.*)$ /imagen.php?id_categoria=1 [QSA,L]
RewriteRule ^contactar/(.*)$ /imagen.php?clave=wsgw_contactar [QSA,L]
RewriteRule ^aviso-legal/(.*)$ /imagen.php?clave=wsgw_aviso_legal [QSA,L]
RewriteRule ^condiciones-de-compra/(.*)$ /imagen.php?id_pagina=40 [QSA,L]
RewriteRule ^politica-de-privacidad/(.*)$ /imagen.php?id_pagina=41 [QSA,L]
# Suyas propias
#PRODUCTOS
RewriteRule ^productos/(.*)$ /imagen.php?id_categoria_productos=1 [QSA,L]
RewriteRule ^producto/(.*)$ /imagen.php?slug_producto=$1 [QSA,L]
RewriteRule ^usadas/(.*)$ /tienda/?pagina_noticias=1&SYSTEM__pId_categoria_xTipo=2&SYSTEM__pId_categoria_xProducto=&SYSTEM__pId_categoria_xProducto_n2=&SYSTEM__pId_marca_xMarca= [QSA,L]
#Nacho 01/03/2017
RewriteRule ^transpaletas/(.*)$ /tienda/?pagina_noticias=1&SYSTEM__pId_categoria_xTipo=1&SYSTEM__pId_categoria_xProducto=55&SYSTEM__pId_categoria_xProducto_n2=&SYSTEM__pId_marca_xMarca=&id_categoria_productos=7&pId_categoria_xTipo=1&pId_categoria_xProducto=55&pId_marca_xMarca= [QSA,L]
#Nacho
#Redirect 301 /imagen.php?clave=wsgw_dominio_verGama&pCodigo=25 https://www.dominio.com/carretillas/
#RewriteRule ^comprar-transpaletas/(.*)$ /tienda/?id_categoria_productos=7&pagina_noticias=1&pId_categoria_xTipo=1&pId_categoria_xProducto=55&pId_marca_xMarca=&SYSTEM__pId_categoria_xTipo=1&SYSTEM__pId_categoria_xProducto=55&SYSTEM__pId_categoria_xProducto_n2=&SYSTEM__pId_marca_xMarca= [QSA,L]
RewriteRule ^carretillas-todoterreno/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=1 [QSA,L]
RewriteRule ^barredoras/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=2 [QSA,L]
RewriteRule ^fregadoras/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=3 [QSA,L]
RewriteRule ^recambios/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=4 [QSA,L]
RewriteRule ^estanterias/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=8 [QSA,L]
RewriteRule ^maquinas-construccion/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=19 [QSA,L]
RewriteRule ^maquinas-portuarias/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=20 [QSA,L]
RewriteRule ^carretillas/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=25 [QSA,L]
RewriteRule ^mb-forklift/(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=27 [QSA,L]
#08/09/2017
RewriteRule ^estanterias-ligeras.html(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=17 [QSA,L]
RewriteRule ^estanteria-convencional.html(.*)$ /imagen.php?clave=wsgw_dominio_verGama&pCodigo=10 [QSA,L]
#FIN 08/09/2017
#RewriteRule ^comprar-transpaletas/(.*)$ /imagen.php?id_categoria_productos=7&pagina_noticias=1&pId_categoria_xTipo=1&pId_categoria_xProducto=55&pId_marca_xMarca=&SYSTEM__pId_categoria_xTipo=1&SYSTEM__pId_categoria_xProducto=55&SYSTEM__pId_categoria_xProducto_n2=&SYSTEM__pId_marca_xMarca= [QSA,L]
#FIN Nacho
RewriteRule ^tienda/(.*)$ /imagen.php?id_categoria_productos=7&SYSTEM__pId_categoria_xTipo=1 [QSA,L]
#CARRITO
RewriteRule ^carrito/(.*)$ /imagen.php?clave=wsgw_tiendaWeb&pAccion=CARRITO [QSA,L]
#NOTICIAS
RewriteRule ^noticia/(.*)$ /imagen.php?slug_noticia=$1 [QSA,L]
#PAGINAS
RewriteRule ^pagina/(.*)$ /imagen.php?slug_pagina=$1 [QSA,L]
#PAGINAS
RewriteRule ^categoria-noticia/(.*)$ /imagen.php?slug_categoria=$1 [QSA,L]
# Redireccion pagina de error
RewriteRule ^error404/(.*)$ /imagen.php?clave=wsgw_gescit_error404 [QSA,L]
ErrorDocument 404 /imagen.php?clave=wsgw_gescit_error404
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 day"
ExpiresByType image/jpeg "access 1 day"
ExpiresByType image/gif "access 1 day"
ExpiresByType image/png "access 1 day"
ExpiresByType text/css "access 1 day"
ExpiresByType text/html "access 1 day"
ExpiresByType application/pdf "access 1 day"
ExpiresByType text/x-javascript "access 1 day"
ExpiresByType application/x-shockwave-flash "access 1 dat"
ExpiresByType image/x-icon "access 1 day"
ExpiresDefault "access plus 1 day"
</IfModule>
## EXPIRES CACHING ##