.htaccess徒步旅行


.htaccess Hijinks

标题很模糊,因为我无法告诉你出了什么问题。我的应用程序与下面的.htaccess文件配合得很好,但在我强制ssl的过程中,出现了一些问题,现在我只收到500个内部服务器错误——既在wamp上,也在一个完全独立的生产主机上,所以它不是服务器。这是我的.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ index.php?/$1 [L]
    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #This last condition enables access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index'.php|(.*)'.swf|images|robots'.txt|css|docs|cache)
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    ErrorDocument 404 /application/errors/404.php
</IfModule>

唯一能解决这个问题的是删除开头的"IfModule"语句。如果我去掉这个条件,只留下所附的代码,并删除整个第二个条件,只剩下这个:

RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index'.php|(.*)'.swf|images|robots'.txt|css|docs|cache)
RewriteRule ^(.*)$ index.php?/$1 [L]

然后应用程序工作,除了整个.htaccess文件被完全忽略!Mod_rewrite也已启用。当我切换到git中的master分支时,我发布的第一个.htaccess仍然运行良好,我不知道是什么改变了我的生活。

有人吗?

确保.htaccess文件具有正确的换行符。参考:http://www.codingforums.com/showthread.php?t=165232.