【问题标题】:.htaccess file and folder with the same name.htaccess 同名文件和文件夹
【发布时间】:2012-08-14 15:39:26
【问题描述】:

我是 .htaccess 的新手,我有一个名为 products.php 的 PHP 文件和一个名为 /products 的同名文件夹。

我想为我网站的产品页面创建一个友好的 URL,我想知道是否可以在 /products 文件夹之外执行 products.php 文件。

我正在使用下面的 .htaccess 代码。

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d

RewriteRule ^products/([a-z0-9-]+)/([0-9]+)/?$ products.php?id=$2&nome=$1 [NC]

谢谢

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    你试过了还是不行?如果没有,请尝试删除此行:

    RewriteCond %{SCRIPT_FILENAME} !-d
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-08
      • 2019-07-27
      • 2021-07-04
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多