【问题标题】:.htaccess ignoring RewriteRule.htaccess 忽略 RewriteRule
【发布时间】:2017-03-09 20:46:33
【问题描述】:

我的 .htaccess 文件中的 RewriteRule 逻辑有问题。

我的查询如下所示:

域/配方/show?id=2

我希望它看起来像这样:

domain/recipe/2/show

我的 .htaccess 文件如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_URI} recipe/(.*)
RewriteRule show/(.*) recipe/show?id=$1

我已经盯着这个看了这么久,我就是看不出问题。我的 htaccess 文件中没有其他内容。

【问题讨论】:

    标签: apache .htaccess url-rewriting


    【解决方案1】:

    你的问题有区别

    /recipe/2/显示

    和你的规则

    显示/(.*)

    或show/2

    如果问题中的 URL 有效,则规则应该看起来像

    RewriteRule ^recipe/(.*?)/show$ recipe/show?id=$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2012-01-16
      • 2015-07-20
      • 1970-01-01
      • 2014-10-06
      • 2011-06-20
      • 2018-04-04
      • 2020-05-30
      • 2013-11-15
      • 2015-12-29
      相关资源
      最近更新 更多