简体   繁体   English

PHP .htaccess具有3个子级别的类别

[英]PHP .htaccess with 3 sub level category

I have .htaccess settings. 我有.htaccess设置。

Original URL: http://localhost/badar/products.php?category=vehicles&product=bus 原始网址: http://localhost/badar/products.php?category = vehicles&product = bus

Rewritten URL: http://localhost/badar/products/vehicles/bus.php 重写的URL: http://localhost/badar/products/vehicles/bus.php

.htaccess code .htaccess代码

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.php$ /products.php?category=$1&product=$2 [L]

When I tried to run the rules and open the URL: http://localhost/products/vehicles/bus.php , I got error: Object not found! 当我尝试运行规则并打开URL: http://localhost/products/vehicles/bus.php ,出现错误: Object not found!

Is there something wrong with that .htaccess code? .htaccess代码有问题吗? Or something missing? 还是缺少什​​么?

And I want to hide .php extension so it will be like this: 而且我想隐藏.php扩展名,所以它将像这样:

http://localhost/products/vehicles/bus

RewriteRule ^products/([A-Za-z0-9-]+)/([0-9]+)/?$ products.php?category=$1&product=$2 [NC,L,QSA] RewriteRule ^ products /([[A-Za-z0-9-] +)/([0-9] +)/?$ products.php?category = $ 1&product = $ 2 [NC,L,QSA]

Use ([A-Za-z0-9-]+) for alphanumeric, ([0-9]+) for numeric, such as IDs; 使用([A-Za-z0-9-]+)表示字母数字,使用([0-9]+)表示数字,例如ID; or use the exact name, such as products . 或使用确切的名称,例如products

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM