没有结束,我想在使用国防部重写转换网页地址一样/目录到/directory/index.html,在一个标准的LAMP托管情况。我所用的地址以斜线结尾。我无法找到处理地址的方法,这些地址不会以斜杠结束。RewriteEngine叙述在.htaccess赶上文件HTML
什么似乎像它应该工作是:
rewriterule ^(.*)/$ $1/index.html [L] /* addresses ending in/*/
rewriterule ^(.*(?!html))$ $1/index.html [L] /* where the problem is */
但第二行导致500服务器错误。如果我加一个字母X到第二行:
rewriterule ^(.*)/$ $1/index.html [L]
rewriterule ^(.*x(?!html))$ $1/index.html [L]
它开始工作,但仅适用于在X结束目录名。我曾尝试用许多不同的东西替换x。任何比真实字符更复杂的东西(如[^ x]或。+)都会导致500服务器错误。
而且,为了满足我自己的好奇心,有谁知道为什么添加一个真实的字母会导致服务器错误和完美运行规则之间的区别?
[接受的答案]由于甘博我能近似使用的RewriteCond的解决方案:
rewritecond %{REQUEST_URI} !\.[^/]+$ rewriterule (.+) $1/index.html [L]
这工作,但过滤器不仅仅是html的 - 它可以阻止其他页面。不幸的是,
rewritecond %{REQUEST_URI} !\.html$
导致服务器错误:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary.
我还是想知道为什么:
rewriterule ^(.*(?!html))$ $1/index.html [L]
结果在一个循环。上半部分应该检查是否不是以.html结尾。自去年下半年以来增加的.html,好像在功能上等同:
while(substr($address,-4)!='html') $address.='html'
很显然,我失去了一些东西。
如果您可以命名服务器错误,它会更有帮助。 – Gumbo 2009-03-03 09:55:42
你没看过我的编辑笔记吗?前瞻断言看起来错误的方向。 – Gumbo 2009-03-10 16:25:26