SE 友好 URL apache 代码片段
我希望将 example.com/23-45 转换为 example.com?id=23-45
您能否发布我应该添加到 .htaccess 文件中的代码以使这项工作 (这是我应该做的一切来完成这项工作 - 将一段代码添加到 .htaccess 文件吗?)
I want example.com/23-45 be transformed to example.com?id=23-45
Could you please post the code I should add to .htaccess file to make this work
(Is this everything I should do to make this work - add a piece of code to .htaccess file?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在 Apache 的 httpd.conf 中启用 mod_rewrite。要使用 .htaccess,您还必须在主配置中为 .htaccess 目录提供
AllowOverride FileInfo
和Options FollowSymLinks
。请参阅文档。之后,根文档目录中的 .htaccess 应该具有:
You have to have mod_rewrite enabled in Apache's httpd.conf. To use a .htaccess, you also have to have
AllowOverride FileInfo
andOptions FollowSymLinks
for the .htaccess directory in the main configuration. See the docs.After that, the .htaccess in the root docs directory should have:
这对我有用
That's what worked for me