【问题标题】:Query string parameters not working on my wordpress project查询字符串参数不适用于我的 wordpress 项目
【发布时间】:2018-08-04 05:42:01
【问题描述】:

我正在开发 WordPress 项目。在我的服务器上运行 php 7.0 并安装了 WordPress 4.9.4。我面临的问题是:我创建了一个模板文件,我正在尝试从 url ?uid=213 print_r($_GET) 查询字符串变量然后它返回 Array() 空数组。

当我在根文件夹上的不同文件上尝试 print_r 语句时,它可以正常工作,但在 functions.php 或模板文件(在 WordPress 页面上)上它不起作用。

谁能告诉我这有什么问题? 下面是我的htaccess文件代码:

# 开始 WordPress 选项 +FollowSymLinks DirectoryIndex index.php 错误文档 404 / 重写引擎开启 RewriteBase / 重写规则 ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] 重写规则 ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] 重写规则。 /index.php [L] # 结束 WordPress

【问题讨论】:

  • 能否分享您的完整网址。
  • @RonakPatel admin.mydemosite.com/user-detail?uid=163 这是我网站的演示网址。
  • "我已经创建了一个模板文件" 你能在你的主题中指定模板文件名吗?
  • 好像你已经在 htaccess 中配置了页面 url。你能发布htaccess代码吗?
  • @vel 下面是我的 htaccess 文件代码。 # BEGIN WordPress Options +FollowSymLinks DirectoryIndex index.php ErrorDocument 404 / RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/) ?(.*\.php)$ $2 [L] 重写规则。 /index.php [L] # 结束 WordPress

标签: php wordpress


【解决方案1】:

检查你的 nginx 配置nginx.conf

你的位置应该是这样的。

# WORDPRESS 
location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-12
    • 2012-05-14
    • 2015-04-09
    • 1970-01-01
    相关资源
    最近更新 更多