开发者

nginx ignoring Apache rewrite directive

My problem is like this: - I now use nginx in front of Apache server wide meaning all my websites - all the rewrites I have in the .htaccess file work perfect, except 1 and up so far noone managed to give me a solution

This is the .htaccess rule

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

This does the following: - it redirects with a 301 http code from www.domain.com/index.html to www.domain.com - it takes both index.html and index.htm

Now the thing is that this worked prior to installing nginx and works so far for index.htm.. it redirects properly. But index.htm does not exist.

I tried the other way around and found out that if the file exists, the redirect WON'T happen.

Another weird thing that I found is the following: I also have mod_pagespeed installed from Google and when I access the URL with www.domain.com/index.html... the one that DOES NOT rewrite to /, this mod_pagespeed is... inactive.. meaning no changes occur in the source for instance....like that URL is not from the same开发者_开发问答 normal requests.

Btw..in ssh when I issue the nginx command I get this:

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 - fake ip

I've looked for the duplicate MIME.. can't find it there and the rest of the bind stuff... not a clue.

If you guys have a clue I'd happily share a virtual mug of beer with you for a good piece of info.

Thanks


This might help.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜