Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有3个子级别类别的PHP.htaccess_Php_.htaccess - Fatal编程技术网

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

带有3个子级别类别的PHP.htaccess,php,.htaccess,Php,.htaccess,我有.htaccess设置 原始URL: 重写的URL: .htaccesscode RewriteEngine On RewriteRule ^([^/]*)/([^/]*)\.php$ /products.php?category=$1&product=$2 [L] 当我尝试运行规则并打开URL时:http://localhost/products/vehicles/bus.php,出现错误:找不到对象 那.htaccess代码有什么问题吗?还是少了什么 我想隐藏.php扩展名

我有
.htaccess
设置

原始URL:

重写的URL:

.htaccess
code

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.php$ /products.php?category=$1&product=$2 [L]
当我尝试运行规则并打开URL时:
http://localhost/products/vehicles/bus.php
,出现错误:
找不到对象

.htaccess
代码有什么问题吗?还是少了什么

我想隐藏
.php
扩展名,因此它将如下所示:

http://localhost/products/vehicles/bus
重写规则^products/([A-Za-z0-9-]+)/([0-9]+)/$ products.php?category=$1和product=$2[NC、L、QSA]

使用
([A-Za-z0-9-]+)
表示字母数字,使用
([0-9]+)
表示数字,如ID;或者使用确切的名称,例如
产品

重写规则^products/([A-Za-z0-9-]+)/([0-9]+)/$ products.php?category=$1和product=$2[NC、L、QSA]


使用
([A-Za-z0-9-]+)
表示字母数字,使用
([0-9]+)
表示数字,如ID;或者使用确切的名称,例如
products

您好,我尝试了您的代码,但仍然没有找到
对象
,我有一个大致的答案:
RewriteRule^/?products/([^/d]+)/?$products.php?category=$1[L,QSA]
,但它只在
http://localhost/products/vehicles/
,我需要的是:
http://localhost/products/vehicles/bus
所以您只需要添加额外的级别类别,如下所示:
重写规则^/?products/([^/d]+)/([^/d]+)/?$products.php?category=$1&category2=$2[L,QSA]
效果。。。干杯,为什么一些url值显示我未找到
对象
,示例:
http://localhost/badar/products/produkterbaru/CT0002
它向我显示未找到的
对象
http://localhost/badar/products/terbaru/CT0002
它正确地显示了我现在得到了:),我添加了您的代码重写规则
([A-Za-z0-9-]+)
您好,我尝试了你的代码,但仍然没有找到
对象
,我有一个大致的答案:
RewriteRule^/?products/([^/d]+)/?$products.php?category=$1[L,QSA]
,但它只在
http://localhost/products/vehicles/
,我需要的是:
http://localhost/products/vehicles/bus
所以您只需要添加额外的级别类别,如下所示:
重写规则^/?products/([^/d]+)/([^/d]+)/?$products.php?category=$1&category2=$2[L,QSA]
效果。。。干杯,为什么一些url值显示我未找到
对象
,示例:
http://localhost/badar/products/produkterbaru/CT0002
它向我显示未找到的
对象
http://localhost/badar/products/terbaru/CT0002
它正确地显示了我现在得到了:),我添加了您的代码重写规则
([A-Za-z0-9-]+)