如何使用 RewriteRules 从 HTML 文件创建干净的 URL?
我目前有这个:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /folder/
RewriteRule ^(.+) $1.html [NC]
我在该文件夹中有 html 页面,并且我希望这些文件为其他页面提供服务。例如:
/folder/about
应该提供 /folder/about.html
/folder/test
应该提供 /folder/test.html问题
是上面的重写脚本给了我一个 500 内部错误。我怎样才能实现我想做的事?
编辑:
我在错误日志中看到此错误:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
I currently have this:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /folder/
RewriteRule ^(.+) $1.html [NC]
I have html pages in that folder
and I want the files to serve other pages. eg:
/folder/about
should serve /folder/about.html
/folder/test
should serve /folder/test.html
The question is that the above rewrite script give me a 500 internal error. How do I achieve what I want to do?
EDIT:
I see this error in the error log:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许存在斜线问题。尝试一下:
如果它不起作用,请尝试:
如果您只想更改字母和数字(例如
wwW.site.com/abdd0456
但不是www. site.com/afdf/sdqfsd
)然后执行类似以下操作:[编辑:添加
L
指令]Maybe there's a slash problem. Try this:
If it doesn't work try:
If you want to change only letters and numbers (e.g.
wwW.site.com/abdd0456
but notwww.site.com/afdf/sdqfsd
) then do something like:[Edit: add the
L
directive]