2

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

找不到对象!

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

如果您认为这是服务器错误,请联系网站管理员。错误 404 localhost 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]

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

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'

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

4

2 回答 2

2

如果您收到 404“未找到”错误,则问题不太可能与您的 htaccess 文件本身有关,尤其是因为您已经在另一台机器上对其进行了测试。htaccess 本身的错误更有可能给出 500 错误。

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

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

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

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

希望有帮助。

于 2013-11-11T12:22:55.433 回答
1

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

于 2013-11-11T12:45:59.023 回答