这是我目前使用的 URL 路径:
/index.php?pid=211
I want to get the URL path as
/index/211/title of the product
如何在 PHP 中创建用户友好的 URL?
以及如何获得“标题”的价值?
问候,
这是我目前使用的 URL 路径:
/index.php?pid=211
I want to get the URL path as
/index/211/title of the product
如何在 PHP 中创建用户友好的 URL?
以及如何获得“标题”的价值?
问候,
在你的 html 代码中,你必须这样写:
<a href='http://www.domain.com/index/211/title-goes-here'>url_text</a>
并在 htaccess 文件中调整以下内容:
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteRule ^([a-zA-Z-]+)$ index.php?action=$1 [NC,L]
RewriteRule ^(member)-([0-9-]+)$ index.php?action=member&id=$2 [NC,L]
RewriteRule ^([a-zA-Z-]+)/([a-zA-Z-]+)-([0-9-]+)$ index.php?action=$1&saction=$2&sid=$3 [NC,L]
RewriteRule ^([a-zA-Z-]+)/([0-9-]+)$ index.php?action=$1&id=$2 [NC,L]
RewriteRule ^([0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/(.*).html$ index.php?action=details&id=$1&p1=$2&p2=$3&p3=$4 [NC,L]