php - 为什么我的重写规则导致所有 ajax 的错误 400?
问题描述
我有一个名为 {HTTP:CF-IPCountry} 的 geoip http 标头,它存储国家/地区代码,例如 FR、US 等。我需要做的是将此查询字符串 loc={HTTP:CF-IPCountry} 添加到网站主页https://example.com/test-website/以及具有以https://example.com/test-website/products/开头的 url 的任何页面,如果在url 所以如果用户请求页面https://example.com/test-website/products/shoe/?size=s它应该重写为https://example.com/test-website/products/shoe/?size= s&loc=我们
这就是 htaccess 文件现在的样子
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test-website/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test-website/index.php [L]
RewriteCond %{QUERY_STRING} !^loc [NC]
RewriteRule (.*) /%{REQUEST_URI}/?loc=%{HTTP:CF-IPCountry} [NC,NE,R,L,QSA]
</IfModule>
# END WordPress
我的最后一个重写器有 2 个我希望解决的问题 1-它在我的网站上的前端和 wordpress 管理面板上导致所有 ajax 出现 400 错误
2-我想将该 rewriteRule 应用到 2 个地方,目前该规则仅适用于主页和https://example.com/test-website/wp-admin/ 我想申请的那两个地方是...... a- 到网站主页https://example.com/test-website/ b- 到所有以https://example.com/test-website/products/开头的页面
谢谢
解决方案
推荐阅读
- javascript - 用户加载页面时刷新一次页面?
- c# - 使用 NAudio 将 wav 文件拆分为字节数组
- python - 如何在分类数据上使用 LogisticRegression?
- java - 如何在 Java 和 Python 之间创建 2 路通信
- c# - Microsoft ReportViewer - 调用 pdf 渲染时缺少 pdb 错误
- laravel - Socket.io laravel,ERR_CONNECTION_REFUSED
- c# - Bot Framework 自适应对话框。如何更改生成器(.lg 文件)?
- python - 删除pickle中的数据
- javascript - 如何制作仅用于水平滚动的粘性导航栏?
- python - 使用 Django 重置密码