【问题标题】:URL Rewriting Works but PHP doesnt take variable with GETURL 重写有效,但 PHP 不使用 GET 变量
【发布时间】:2023-03-04 01:53:01
【问题描述】:

服务器移动后我的 htaccess 重写规则存在一些问题。

出于任何原因,我的旧指令不再起作用。

我的 htacess 有以下行:

RewriteEngine On
RewriteRule ^ads/mobile/([a-z0-9_-]+)/?$ /ads.php?ptid=6&tube_id=$1 [NC,L]

我没有收到任何 500 或 404 错误。 url栏显示重写模式下的url OK, 但是 php 不会从重写的 url 中获取 GET var。

如果我使用 url 上的变量访问 ads.php,它就完美了。

有什么想法吗? 我从 NC,L 更改为 QSA,并且我删除了 ads.php 之前的“/”,但没有任何效果。

我会感谢任何帮助。我在这里搜索了类似的东西,但对我没有用。

【问题讨论】:

  • 注意:mod_rewrite 在 apache 中是启用的
  • 这是一个工作示例RewriteRule ^(.+)$ index.php?url=$1 [QSA,L],如果有帮助的话。

标签: php .htaccess mod-rewrite url-rewriting get


【解决方案1】:

这很可能是由于启用了MultiViews 选项。

将此行放在您的 .htaccess 顶部将其关闭:

Options -MultiViews

【讨论】:

    【解决方案2】:

    最后是我的错。 它不起作用,因为我没有将文件 /etc/apache2/(site) 上的 allowoverride 设置从 NONE 更改为 ALL

    现在可以了! 谢谢

    【讨论】:

      猜你喜欢
      • 2016-05-08
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      相关资源
      最近更新 更多