如何在 htaccess 中重写 SEO 友好的 url

问题描述:

如何创建一个像 example.com/pages/my-first-page/followers 这样的 SEO 友好 URL 我想如何在 if(isset($_GET['followers'])){...}htaccess 文件.

How to create an SEO friendly URL like example.com/pages/my-first-page/followers here I want how to create a structure in if(isset($_GET['followers'])){...} and htaccess file.

我的链接工作正常,直到 example.com/pages/my-first-page/ 但现在我想添加 followers 部分.我希望我能很好地解释我的期望.感谢您的帮助

My link working fine till example.com/pages/my-first-page/ but now I want to add followers section. I hope i explain well what I expecting. Thanks for your help

您建议的规则是:

RewriteRule ^pages/([\w-]+)/followers/?$ page.php?pages=$1&followers=1 [QSA,NC,L]

这是一个很好的规则,没有理由不可行.确保此规则位于之前页面规则,这是您在 .htaccess 中的第一条规则

This is pretty good rule and there is no reason why it should not work. Make sure this rule is placed before page rule which is your first rule in .htaccess