.htaccess文件在Windows 7中创建,但在Ubuntu 12.10中不起作用


.htaccess file created in windows 7 but does not work in Ubuntu 12.10

我用 PHP 5.5 开发了一个项目,它有一个.htaccess文件。我的整个项目在 Windows 7 中运行良好。在 Ubuntu 12.10 中,每当我尝试检查我的项目时,我都会收到此错误消息。

找不到对象!

在此服务器上找不到请求的 URL。如果您手动输入了 URL,请检查您的拼写,然后重试。

如果您认为这是服务器错误,请与网站站长联系。 错误 404 本地主机 Apache/2.4.4 (Unix) OpenSSL/1.0.1e PHP/5.5.3 mod_perl/2.0.8-dev Perl/v5.16.3

我的.htaccess文件如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

日志文件夹中有两种类型的文件用于错误:

Path: /opt/lampp/logs
error_log
php_error_log

error_log文件包含以下内容:

[Wed Oct 16 05:38:11.044023 2013] [ssl:warn] [pid 5479] AH01906: RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Wed Oct 16 05:38:11.044087 2013] [ssl:warn] [pid 5479] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Wed Oct 16 05:38:11.044110 2013] [suexec:notice] [pid 5479] AH01232: suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)
[Wed Oct 16 05:38:11.111342 2013] [auth_digest:notice] [pid 5480] AH01757: generating secret for digest authentication ...
[Wed Oct 16 05:38:12.041421 2013] [ssl:warn] [pid 5480] AH01906: RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Wed Oct 16 05:38:12.041443 2013] [ssl:warn] [pid 5480] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Wed Oct 16 05:38:12.041470 2013] [lbmethod_heartbeat:notice] [pid 5480] AH02282: No slotmem from mod_heartmonitor
[Wed Oct 16 05:38:12.047802 2013] [mpm_prefork:notice] [pid 5480] AH00163: Apache/2.4.4 (Unix) OpenSSL/1.0.1e PHP/5.5.3 mod_perl/2.0.8-dev Perl/v5.16.3 configured -- resuming normal operations
[Wed Oct 16 05:38:12.047835 2013] [core:notice] [pid 5480] AH00094: Command line: '/opt/lampp/bin/httpd -E /opt/lampp/logs/error_log -D SSL -D PHP'
[Wed Oct 16 05:41:38.971308 2013] [mpm_prefork:notice] [pid 5480] AH00169: caught SIGTERM, shutting down
[Mon Nov 11 05:36:18.038713 2013] [ssl:warn] [pid 5603] AH01906: RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Nov 11 05:36:18.050161 2013] [ssl:warn] [pid 5603] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Mon Nov 11 05:36:18.050220 2013] [suexec:notice] [pid 5603] AH01232: suEXEC mechanism enabled (wrapper: /opt/lampp/bin/suexec)
[Mon Nov 11 05:36:18.117059 2013] [auth_digest:notice] [pid 5604] AH01757: generating secret for digest authentication ...
[Mon Nov 11 05:36:19.135320 2013] [ssl:warn] [pid 5604] AH01906: RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Nov 11 05:36:19.135347 2013] [ssl:warn] [pid 5604] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Mon Nov 11 05:36:19.135377 2013] [lbmethod_heartbeat:notice] [pid 5604] AH02282: No slotmem from mod_heartmonitor
[Mon Nov 11 05:36:19.215465 2013] [mpm_prefork:notice] [pid 5604] AH00163: Apache/2.4.4 (Unix) OpenSSL/1.0.1e PHP/5.5.3 mod_perl/2.0.8-dev Perl/v5.16.3 configured -- resuming normal operations
[Mon Nov 11 05:36:19.215511 2013] [core:notice] [pid 5604] AH00094: Command line: '/opt/lampp/bin/httpd -E /opt/lampp/logs/error_log -D SSL -D PHP'

我的设置有什么问题?请指导我。

如果您收到 404"未找到"错误,那么问题不太可能出在您的 htaccess 文件本身,特别是因为您已经在另一台计算机上对其进行了测试。htaccess 本身的错误更有可能给出 500 错误。

这里最可能的问题是您的文件名大小写不正确。

Windows

不区分大小写,因此例如 Windows 会将名为 Index.PHP 的文件与 index.php 完全相同。但是,Linux 区分大小写,因此它会将它们视为两个不同的文件。

对于在Windows上开发并移植到Linux的代码来说,文件名大小写有问题,这是一个非常常见的错误。

检查你的文件名;确保所有内容的命名一致(我建议全小写),无论是它们的命名方式还是链接到它们的方式。

希望有帮助。

看起来你在 Ubuntu 主机上启用了 SELinux。尝试使用中给出的方法之一禁用它: http://www.thegeekstuff.com/2009/06/how-to-disable-selinux-redhat-fedora-debian-unix/

相关文章: