简体   繁体   English

基于url的php动态表页内容

[英]php dynamic table page content based on url

i'm developing site to show car parts/accessories in table format.我正在开发网站以表格格式显示汽车零件/配件。

My question is If user search accessories.com/ car name , the table content only show that particular car name accessories/parts only.我的问题是如果用户搜索 Accessories.com/car name ,表格内容仅显示特定的汽车名称配件/零件。 How to get a car name from URL and add dynamically to the query.如何从 URL 获取汽车名称并动态添加到查询中。

projctfile/index.php项目文件/索引.php

$url='accessories.com/tesla3';
$r = parse_url($url);

$path = explode('/',$r['path']);

echo $path[1];

it return page not found error.它返回页面未找到错误。

If you're using Apache, put this into .htaccess file in your folder:如果您使用的是 Apache,请将其放入文件夹中的 .htaccess 文件中:

RewriteEngine on
RewriteRule "^([a-zA-Z0-9]+)$" "index.php"

https://httpd.apache.org/docs/2.4/rewrite/intro.html https://httpd.apache.org/docs/2.4/rewrite/intro.html

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

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