.htaccess 中的 SEO 友好 URL 命令
我有一个如下所示的动态页面:
www.sitedomain.com/page.php?id=30&name=about_our_company
我想通过如下内容使我的网站链接 SEO 友好:
www.sitedomain.com/about_our_company.html
或者
www.sitedomain.com/about_our_company
我的问题是: .htaccess 文件中应该有什么正则表达式/代码?
谢谢
I have a dynamic page that looks like the following:
www.sitedomain.com/page.php?id=30&name=about_our_company
I want to make my website links SEO friendly by having something like the following:
www.sitedomain.com/about_our_company.html
Or
www.sitedomain.com/about_our_company
My question is: what regex/code I should have in the .htaccess file?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此 ofc 的固定 ID 为
30
。This ofc has a fixed id of
30
.由于
/about_our_company
不包含 ID,因此不可能正确创建 ID。我在自己的 CMS 中执行此操作的方法是在 .htaccess 中包含类似的内容:
然后在 index.php 中,使用
$_REQUEST['page']
(假设是 PHP)变量来查找数据库中的右页详细信息since
/about_our_company
doesn't include the ID, it's impossible to invent the ID correctly.the way I do it in my own CMS is to have something like this in the .htaccess:
then in index.php, use the
$_REQUEST['page']
(assuming PHP) variable to find the right page details in the database您可以将其改进为更通用:
以下 URL 将全部匹配:
You could improve this to be more generic:
The following URL's would all match: