php - .htaccess 狂欢

标签 php .htaccess codeigniter

标题含糊不清,因为我无法告诉你出了什么问题。我的应用程序可以与下面的 .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 中的主分支时,我发布的第一个 .htaccess 仍然工作正常,而且我无法弄清楚是什么对我的生活产生了影响。

有人吗?

最佳答案

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

关于php - .htaccess 狂欢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12147095/

相关文章:

php - Magento 中的 CSV 导入/导出问题

php - Codeigniter - 重命名 Controller 301 重定向旧 url

codeigniter - Codeigniter 中的 insert_id() 在查询失败时返回 false 吗?

.htaccess 规则,在 url 中重写 key

php - 如何在codeigniter中将http重定向到https

php服务器端打印

php - 在 PHP 中转换时间戳

php - 无法在 php 和 mysqli_query 上提交表单

java - 如何保护文件,使其只能由 java 访问?

.htaccess - 无效命令导致 htaccess 内部服务器错误 'Header'