nginx忽略Apache重写指令

时间:2011-05-11 14:04:05

标签: apache redirect nginx rewrite

我的问题是这样的: - 我现在在Apache服务器范围前使用nginx意味着我所有的网站 - 我在.htaccess文件中的所有重写工作都很完美,除了1和以上没有人设法给我一个解决方案

这是.htaccess规则

 -------------
    RewriteCond %{THE_REQUEST} ^.*/index\.(html|htm)\ HTTP/
    RewriteRule ^(.*)index\.(html|htm)$ http://%{HTTP_HOST}/$1 [R=301,L]
 -------------

执行以下操作: - 它使用来自www.domain.com/index.html的301 http代码重定向到www.domain.com - 它需要index.html和index.htm

现在的问题是,这在安装nginx之前有效,并且目前为index.htm工作..它正确地重定向。 但是index.htm不存在。

我尝试了相反的方法,发现如果文件存在,重定向就不会发生。

我发现的另一个奇怪的事情如下:我还从谷歌安装了mod_pagespeed,当我使用www.domain.com/index.html访问该网址时...那个不会重写为/的网址,这个mod_pagespeed是...不活动..意味着源中没有发生任何变化....例如,该URL不是来自相同的正常请求。

顺便说一下,当我发出nginx命令时,我得到了这个:

nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/nginx.conf:30
nginx: [emerg] bind() to 111.111.111.111:80 failed (98: Address already in use)
nginx: [emerg] bind() to 111.111.111.111:80 failed (98: Address already in use)
nginx: [emerg] bind() to 111.111.111.111:80 failed (98: Address already in use)
nginx: [emerg] bind() to 111.111.111.111:80 failed (98: Address already in use)
nginx: [emerg] bind() to 111.111.111.111:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

111.111.111.111 - 假ip

我已经找了重复的MIME ..在那里找不到它和剩下的绑定东西...... 不是线索。

如果你们有一个线索,我很乐意与你分享一杯啤酒,以获得一些信息。

由于

1 个答案:

答案 0 :(得分:-1)

这可能会有所帮助。

RewriteCond %{THE_REQUEST} ^.*/index\.(html|htm)\ HTTP/ [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)index\.(html|htm)$ http://%{HTTP_HOST}/$1 [R=301,L]