Prestashop: share on social link invalid

Created on 28 Dec 2018  路  15Comments  路  Source: PrestaShop/PrestaShop

Prestashop 1.7.5.0
Informazioni sul server Linux #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64
Versione software del server: nginx/1.14.1
Versione di PHP: 7.2.13
If I follow this #10156 rewrite doesn't works.
So I've deactivated it
All works well (without rewrite) only the products share link is too long, so the shared link is invalid.
Try for example with this product: https://www.100asa.it/index.php?id_product=8064&id_product_attribute=0&rewrite=grandstream-rfid-tag-125khz-per-gds3710-hd-door-system&controller=product&id_lang=1
the twitter link show only https://www.100asa.it/index.php?id_product=8064

1.7.4.4 1.7.5.0 Bug FO Minor No change required Socialsharing

All 15 comments

Now I've restored apache, use .htaccess and url rewrite.
1.7.5 seems doesn't works well with nginx

Hi @centoasa

Is your problem solved?

Thanks,
Khouloud

@khouloudbelguith Solved disabling nginx and restore apache.
But if you've an installation with nginx as engine, you can ceck as I said.

Hi @centoasa,

Thank you for your report.
We'll first try to reproduce it and we'll come back to you if we need more information.

Best regards,
Khouloud

Hi @centoasa,

Yes, I manage to reproduce the issue with PS1.7.5.0 & nginx & friendly URL is disabled the the link of a product shared is not correct.
I attached a video record.
https://drive.google.com/file/d/1oCY_IZJ5LffanSLxgVrJTWUTcurznzZs/view
When I use nginx & friendly URL is enabled => OK.
https://drive.google.com/file/d/1u9fSniGKEXhJLTFAvsH6Iys7A5akpV2m/view
We will see how to fix it.
Thanks!

@khouloudbelguith please, can you post me the full prestashop.conf nginx configuration to have full link rewrite (all core links, modules, etc)

@centoasa, here's my nginx configuration

server {
    listen   80; ## listen for ipv4; this line is default and implied
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www/html;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name _;

    # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
    sendfile off;

    # Add stdout logging
    # Add stdout logging
        error_log /var/log/nginx/error.log info;
        access_log /var/log/nginx/access.log;

        # Add option for x-forward-for (real ip when behind elb)
        #real_ip_header X-Forwarded-For;
        #set_real_ip_from 172.16.0.0/12;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to index.html
        try_files $uri $uri/ /1750/index.php?$args;
        # Images
                rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last;
                rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
                rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
                rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
                rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
                rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
                rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
                rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
                rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last;
                rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last;
        # AlphaImageLoader for IE and fancybox
        rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last;

        # Web service API
        rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;

        # Installation sandbox
        rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last;
    }
    # Gzip Settings, convert all types.
        gzip on;
        gzip_vary on;
        gzip_proxied any;

        # Can be enhance to 5, but it can slow you server
        # gzip_comp_level    5;
        # gzip_min_length    256;

        gzip_types
            application/atom+xml
            application/javascript
            application/json
            application/ld+json
            application/manifest+json
            application/rss+xml
            application/vnd.geo+json
            application/vnd.ms-fontobject
            application/x-font-ttf
            application/x-web-app-manifest+json
            application/xhtml+xml
            application/xml
            font/opentype
            image/bmp
            image/svg+xml
            image/x-icon
            text/cache-manifest
            text/css
            text/plain
            text/vcard
            text/vnd.rim.location.xloc
            text/vtt
            text/x-component
            text/x-cross-domain-policy;

        gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    # Symfony controllers
        location /1750/admin-dev/ {                                  # [REQUIRED EDIT] the name of your admin directory
            if (!-e $request_filename) {
                rewrite ^/.*$ /1750/admin-dev/index.php last;   # [REQUIRED EDIT] the name of your admin directory
            }
        }

        # Cloudflare / Max CDN fix
        location ~* \.(eot|otf|ttf|woff|woff2)$ {
            add_header Access-Control-Allow-Origin *;
        }

        # Do not save logs for these
        location = /1750/favicon.ico {
            log_not_found off;
            access_log off;
        }
        location = /1750/robots.txt {
            auth_basic off;
            allow all;
            log_not_found off;
            access_log off;
        }


    error_page 404 /1750/index.php?controller=404;

        location ^~ /sad.svg {
            alias /var/www/errors/sad.svg;
            access_log off;
        }
        location ^~ /twitter.svg {
            alias /var/www/errors/twitter.svg;
            access_log off;
        }
        location ^~ /gitlab.svg {
            alias /var/www/errors/gitlab.svg;
            access_log off;
        }

    # pass the PHP scripts to FastCGI server listening on socket
    #
    location ~ \.php$ {
                try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
    }

        location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
                expires           5d;
        }

    # deny access to . files, for security
    #
    location ~ /\. {
            log_not_found off; 
            deny all;
    }

    location ^~ /.well-known {
                allow all;
                auth_basic off;
        }

}

Thanks!

@khouloudbelguith thank you so much!
ps: https://www.100asa.it/it/index.php?controller=newproducts
https://www.100asa.it/it/index.php?controller=bestsales
I don't understand why doesn't rewrite

This is a different issue, can you open a new one with more information about your second issue.
Thanks!

remaining on this argoument, why if I don't add:

try_files $fastcgi_script_name /index.php$uri&$args;
after ~ .php(/.*)?$ {
and
try_files $uri $uri/ /index.php?$args;
after ~ /$ {

in nginx_ip_default.conf, my site with rewrite url doesn't works?

@centoasa, this is the configuration proposed by PrestaShop https://github.com/PrestaShop/PrestaShop/blob/develop/docs/docker/nginx_fpm/prestashop-nginx/prestashop-nginx.conf#L81

@PierreRambaud what do you think?
Thanks!

I will have a look as soon as possible :)

If you need to run a multishop or multilang instance:
https://github.com/PrestaShop/PrestaShop/pull/12082/files

@centoasa Is it solved ? Can this issue be closed ?

@marionf yes, you can close this. I'm back to apache+nginx (proxy)

Was this page helpful?
0 / 5 - 0 ratings