I have a Wordpress e-commerce (With Woocommerce) running on my VPS (With Caddy -> NGinx)
我在我的VPS上运行了Wordpress电子商务(使用Woocommerce)(使用Caddy - > NGinx)
Before i had index.php in my uri so i added in my config file theses lines to rewrite uri and be able to activate pretty links.
之前我在我的uri中有index.php所以我在配置文件中添加了这些行来重写uri并能够激活漂亮的链接。
Perfect, it works ! Now i have www.myWebsite.com/shop/ instead of www.myWebsite.com/index.php/shop/
完美,它的作品!现在我有www.myWebsite.com/shop/而不是www.myWebsite.com/index.php/shop/
But, this create an error in Woocommerce cart. Indeed, i can't anymore fast-add product in my cart and checkout. I have this JSON Error :
但是,这会在Woocommerce购物车中造成错误。事实上,我不能再在我的购物车和结账时快速添加产品了。我有这个JSON错误:
Unexpected token < in JSON at position 0
Of course, i search on Stack and Google, a lot of people have this issue but not for the same reason. So i try to disable mod_rewrite and.... tadaaa it's work.
当然,我在Stack和Google上搜索,很多人都有这个问题但不是出于同样的原因。所以我尝试禁用mod_rewrite和.... tadaaa它的工作。
So do you know how fix this issue with Woocommerce and Mod_rewrite ?
所以你知道如何解决Woocommerce和Mod_rewrite这个问题吗?
Thank's
1 个解决方案
#1
0
I fix the problem. I don't know why this rewrite work better than the old one... If someone can explain to me !
我解决了这个问题。我不知道为什么这个重写比旧的更好...如果有人能向我解释!
The old mod_rewrite :
旧的mod_rewrite:
rewrite {
regexp .*
ext /
to /index.php?_url={uri}
}
The new one who fixed the issue :
解决问题的新人:
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?{query}
}
Now, i can add to cart and checkout it's work. Prefer the second rewrite example if you have the same issue.
现在,我可以添加到购物车并结帐它的工作。如果您遇到同样的问题,请首选第二个重写示例。
#1
0
I fix the problem. I don't know why this rewrite work better than the old one... If someone can explain to me !
我解决了这个问题。我不知道为什么这个重写比旧的更好...如果有人能向我解释!
The old mod_rewrite :
旧的mod_rewrite:
rewrite {
regexp .*
ext /
to /index.php?_url={uri}
}
The new one who fixed the issue :
解决问题的新人:
rewrite {
if {path} not_match ^\/wp-admin
to {path} {path}/ /index.php?{query}
}
Now, i can add to cart and checkout it's work. Prefer the second rewrite example if you have the same issue.
现在,我可以添加到购物车并结帐它的工作。如果您遇到同样的问题,请首选第二个重写示例。