【问题标题】:Apache htacces redirects to 404Apache htaccess 重定向到 404
【发布时间】:2016-06-05 15:17:50
【问题描述】:

我有这个链接,我可以访问:

 http://domain.com/search/csgo/US/nameorip/?matching=dust2

.htaccess 看起来像这样:

RewriteRule ^search/([a-z_]+)/([A-Z_]+)/([a-z]+)/?matching=(.*)?$   servers.php?game=$1&location=$2&query_by=$3&matching=$4 [NC,L]  

访问此链接后,我也被重定向到 404 页面。为什么 ?我的.htacces 文件有什么问题?

编辑:我阅读了文档,我认为matching 有问题,对吧?

【问题讨论】:

  • 没错。您无法检查重写模式中的查询字符串。您需要使用RewriteCond %{QUERY_STRING} ^matching=([^&])$ [NC] 进行检查。
  • 抱歉,将+ 留在那里 - 应该是[^&]+,如下面的答案所示。

标签: php .htaccess http-status-code-404


【解决方案1】:

你可以试试:

RewriteCond %{QUERY_STRING} ^matching=([^&]+)$ [NC]
RewriteRule ^search/([a-z_]+)/([A-Z_]+)/([a-z]+)/?$ servers.php?game=$1&location=$2&query_by=$3&matching=%1 [NC,L]

【讨论】:

    猜你喜欢
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    相关资源
    最近更新 更多