首页 > 解决方案 > Codeigniter3 中的 .htaccess 错误

问题描述

我在托管帐户中有一个网站文件。这是目录根目录中的这个 .htaccess 文件

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L]

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}
#AddHandler application/x-httpd-php56 .php .php5 .php4 .php3

另外,我在根目录中添加了一个新的网站文件夹“nigaratakishizadeh.com”并将我的 CI 文件上传到那里。当我进入网站 ( http://nigaratakishizadeh.com ) 时,它给了我一个错误 500 Internal

500 - 内部服务器错误 这是一个临时的服务器错误。请稍后尝试重新加载网页。

但是,当我将 nigaratakishizadeh.com 文件夹的 htaccess 更改为 RewriteEngine 时,它​​会打开网站。问题是什么?

这是我在 nigaratakishizadeh.com 目录中的 .htaccess 文件:

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

php_value upload_max_filesize 30M

这是服务器 apache 错误日志:

[Sun Apr 29 08:16:29.548592 2018] [core:alert] [pid 33453] [client 181.224.135.93:39158] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:29.341526 2018] [core:alert] [pid 38466] [client 181.224.135.93:39098] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:27.622224 2018] [core:alert] [pid 43795] [client 181.224.135.93:38904] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:27.261333 2018] [core:alert] [pid 42837] [client 181.224.135.93:38864] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:23.581238 2018] [core:alert] [pid 38407] [client 181.224.135.93:38614] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:22.294281 2018] [core:alert] [pid 38523] [client 181.224.135.93:38538] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:20.994017 2018] [core:alert] [pid 38526] [client 181.224.135.93:38430] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:20.778064 2018] [core:alert] [pid 36546] [client 181.224.135.93:38378] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:20.778064 2018] [core:alert] [pid 38523] [client 181.224.135.93:38376] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:20.042254 2018] [core:alert] [pid 42837] [client 181.224.135.93:38276] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:20.009329 2018] [core:alert] [pid 33453] [client 181.224.135.93:38266] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:19.804285 2018] [core:alert] [pid 38528] [client 181.224.135.93:38236] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:19.742617 2018] [core:alert] [pid 38527] [client 181.224.135.93:38228] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:19.535860 2018] [core:alert] [pid 38526] [client 181.224.135.93:38124] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:19.178688 2018] [core:alert] [pid 38528] [client 181.224.135.93:38038] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:18.973287 2018] [core:alert] [pid 38466] [client 181.224.135.93:37990] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:18.383334 2018] [core:alert] [pid 38526] [client 181.224.135.93:37862] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:18.173713 2018] [core:alert] [pid 42837] [client 181.224.135.93:37826] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:06.847039 2018] [core:alert] [pid 38523] [client 181.224.135.93:35942] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:05.703058 2018] [core:alert] [pid 33453] [client 181.224.135.93:35858] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:05.101583 2018] [core:alert] [pid 38527] [client 181.224.135.93:35786] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:04.895922 2018] [core:alert] [pid 42837] [client 181.224.135.93:35756] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:04.391211 2018] [core:alert] [pid 38526] [client 181.224.135.93:35702] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:16:04.122189 2018] [core:alert] [pid 42837] [client 181.224.135.93:35648] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration, referer: http://nigaratakishizadeh.com/
[Sun Apr 29 08:16:03.218603 2018] [core:alert] [pid 38526] [client 181.224.135.93:35530] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:11:50.044065 2018] [core:alert] [pid 7912] [client 181.224.135.93:33050] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:48.010489 2018] [core:alert] [pid 7912] [client 181.224.135.93:60890] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:47.751755 2018] [core:alert] [pid 14231] [client 181.224.135.93:60852] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:46.422532 2018] [core:alert] [pid 2990] [client 181.224.135.93:60692] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:19.255974 2018] [core:alert] [pid 12220] [client 181.224.135.93:56988] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:15.718812 2018] [core:alert] [pid 2522] [client 181.224.135.93:56666] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:15.490073 2018] [core:alert] [pid 12918] [client 181.224.135.93:56638] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:15.320300 2018] [core:alert] [pid 8370] [client 181.224.135.93:56608] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:14.989071 2018] [core:alert] [pid 12918] [client 181.224.135.93:56570] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:10.808651 2018] [core:alert] [pid 12918] [client 181.224.135.93:56064] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:10.426044 2018] [core:alert] [pid 12918] [client 181.224.135.93:56020] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:09.269472 2018] [core:alert] [pid 12220] [client 181.224.135.93:55938] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:08.937889 2018] [core:alert] [pid 2828] [client 181.224.135.93:55904] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:11:08.323260 2018] [core:alert] [pid 2522] [client 181.224.135.93:55872] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:10:33.954696 2018] [core:alert] [pid 56003] [client 181.224.135.93:53066] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:10:28.173501 2018] [core:alert] [pid 7912] [client 181.224.135.93:52686] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:10:27.670770 2018] [core:alert] [pid 2990] [client 181.224.135.93:52664] /home/javid020/public_html/nigaratakishizadeh.com/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
[Sun Apr 29 08:09:37.739238 2018] [core:alert] [pid 2990] [client 181.224.135.93:51750] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:34.847641 2018] [core:alert] [pid 2990] [client 181.224.135.93:51550] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:34.640236 2018] [core:alert] [pid 45433] [client 181.224.135.93:51530] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section, referer: https://www.wtf.az/courses
[Sun Apr 29 08:09:33.541211 2018] [core:alert] [pid 3110] [client 181.224.135.93:51446] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:33.321420 2018] [core:alert] [pid 50479] [client 181.224.135.93:51440] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section, referer: https://www.wtf.az/courses
[Sun Apr 29 08:09:33.124587 2018] [core:alert] [pid 2828] [client 181.224.135.93:51426] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:32.919041 2018] [core:alert] [pid 7834] [client 181.224.135.93:51408] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section, referer: https://www.wtf.az/courses
[Sun Apr 29 08:09:32.820198 2018] [core:alert] [pid 3110] [client 181.224.135.93:51402] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:13.463839 2018] [core:alert] [pid 45433] [client 181.224.135.93:49724] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:13.320793 2018] [core:alert] [pid 3110] [client 181.224.135.93:49716] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:13.258574 2018] [core:alert] [pid 2990] [client 181.224.135.93:49710] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section, referer: https://www.wtf.az/courses
[Sun Apr 29 08:09:12.506714 2018] [core:alert] [pid 2990] [client 181.224.135.93:49654] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section, referer: https://www.wtf.az/courses
[Sun Apr 29 08:09:11.796429 2018] [core:alert] [pid 2828] [client 181.224.135.93:49580] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section
[Sun Apr 29 08:09:10.569661 2018] [core:alert] [pid 39620] [client 181.224.135.93:49444] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section, referer: https://www.wtf.az/courses
[Sun Apr 29 08:09:09.945440 2018] [core:alert] [pid 39620] [client 181.224.135.93:49404] /home/javid020/public_html/.htaccess: </IfModule without matching <IfModule section

标签: .htaccesscodeigniter

解决方案


文件中的每一行.htaccess都是正确的。

您收到500 - 内部服务器错误,因为您无权设置这些值.htaccess

您必须联系您的 Web 服务器提供商并要求AllowOverride为您的主机设置选项或将这些行放在他们的虚拟主机配置文件中。

请参阅ApacheAllowOverride指令


推荐阅读