.htaccess 如何使用重写规则从HTML文件生成干净的URL?

.htaccess 如何使用重写规则从HTML文件生成干净的URL?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我目前有: Options +FollowSymlinks RewriteEngine On RewriteBase /folder/ RewriteRule ^(.+) $1.html [NC] 我在文件夹中有html页面,我希望这些文件可以服务于其他页面。例如: /folder/about应提供/folder/about.html /folder/test应提供/folder/test.html 问题是上面的重写脚本给了我500个内部错误。我如何实现我想做的事 编辑: 我在错误日志中看到

我目前有:

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.

也许有个斜线问题。试试这个:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /folder/
RewriteCond $1 !\.html$
RewriteRule (.*) $1.html [QSA,NC,L]
如果不起作用,请尝试:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /folder
RewriteCond $1 !\.html$
RewriteRule (.*) $1.html [QSA,NC,L]
如果只想更改字母和数字(例如
wwW.site.com/abdd0456
wwW.site.com/afdf/sdqfsd
),请执行以下操作:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /folder/
RewriteCond $1 !\.html$
RewriteRule ([a-zA-Z0-9]*) $1.html [QSA,NC,L]

[编辑:添加
L
指令]

mod rewrite显示的另一页是什么?你是什么意思/folder/about应该可以看到/folder/about.htmlw中的内容当您尝试查看这些重写规则时发生了什么?基本上。。。你的问题是什么?:)编辑我的问题。htaccess脚本基本上不起作用,您的规则起作用,但原因是错误的。OPs查询正在执行内部重定向并生成
about.html.html.html…
等。索普只需添加
RewriteCond$1!\。html$
在规则确定之前,您是对的。并且可能添加
L
='Last rewrite'条件。。。更新了我的答案。