将不带 .html 扩展名的链接重定向为带 .html 扩展名的链接
更改网站结构后,我需要重定向链接的帮助。如何将所有没有 .html 扩展名的链接重定向到同一链接但具有 .html 扩展名?我不想重定向的唯一链接是/admin。
Example: google.com/hey -> google.com/hey.html
google.com/hey.html -> do nothing
google.com/admin -> do nothing
提前致谢
After changing my site structure I need help redirecting links. How can I redirect all links that don't have a .html extension to the same link but with .html extension? The only link I don't want redirected is /admin.
Example: google.com/hey -> google.com/hey.html
google.com/hey.html -> do nothing
google.com/admin -> do nothing
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哦,对不起,试试这个人。错误出现在重写条件中。
Ohh sorry, try this man. The error was in the rewritecond.
如果这些链接是页面链接而非外部链接,.htaccess 解决方案可能会有所帮助。
首先请注意,仅当您无权访问服务器配置时才使用 htaccess,因为 htaccess 会降低服务器速度。那里配置的所有内容也可以在 .httpdconf 中配置。
抱歉,我还没有测试下面发布的代码,但请告诉我它是否有效。
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
If these links are onpage links an non external ones a .htaccess solution could help.
First be aware to use htaccess only if you do not have access to the server config, because htaccess slows the server down. Everything configured there can be configured as well in the .httpdconf
Sorry, I have not tested the code posted bellow but tell me if it has worked.
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html