baldden Posted May 1, 2015 Share Posted May 1, 2015 Hello! I have error 404 if url don't have slash at the end of. for example: url work fine: https://satam.kz/lenovo/269-lenovo-s750/ url 404 error: https://satam.kz/lenovo/269-lenovo-s750 How fix it, i want work two url. I don't use apache, only nginx. nginx.conf: location / { root /var/www/allwww/data/satam.kz; index index.php; rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last; rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.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.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.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.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.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.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.jpg last; rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last; rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last; location /blog { try_files $uri $uri/ /blog/index.php?$args; } #try_files $uri $uri/ /index.php?$args; try_files $uri $uri/ /index.php?q=$uri&$args; } Link to comment Share on other sites More sharing options...
PascalVG Posted May 2, 2015 Share Posted May 2, 2015 Maybe this helps: http://www.nginxtips.com/add-trailing-slash-nginx/ My 2 cents, pascal Link to comment Share on other sites More sharing options...
baldden Posted May 5, 2015 Author Share Posted May 5, 2015 Thanks! it work fine: rewrite ^([^\?#]*/)([^\?#\./]+)([\?#].*)?$ $1$2/$3 permanent; Link to comment Share on other sites More sharing options...
PascalVG Posted May 6, 2015 Share Posted May 6, 2015 Good to hear. Thanks for the feedback! Happy selling, pascal Link to comment Share on other sites More sharing options...
baldden Posted May 6, 2015 Author Share Posted May 6, 2015 (edited) Not work if add rewrite ^([^\?#]*/)([^\?#\./]+)([\?#].*)?$ $1$2/$3 permanent; then https://satam.kz/order-history/ and https://satam.kz/quick-order/ error 404 Edited May 6, 2015 by baldden (see edit history) Link to comment Share on other sites More sharing options...
baldden Posted May 14, 2015 Author Share Posted May 14, 2015 any ideas? Link to comment Share on other sites More sharing options...
Skafander Posted February 2, 2020 Share Posted February 2, 2020 Somebody got answer for this? Adding global directive in nginx gives 404 in some modules, ex. our cart. Our products and categories works only if there's "/" at the end of link. Removing it causes soft 404 error I do not want to modify links in Preferences -> SEO as we are already indexed in google with the "/". I would like to just 301 categories and products that don't have "/" to the one WITH "/" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now