【问题标题】:.htaccess file created in windows 7 but does not work in Ubuntu 12.10.htaccess 文件在 Windows 7 中创建但在 Ubuntu 12.10 中不起作用
【发布时间】:2013-11-23 05:40:48
【问题描述】:

我用 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]

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'

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

【问题讨论】:

  • 错误日志中有什么内容?
  • 如果您删除此 .htaccess 然后尝试访问您的网站,它会起作用吗?
  • 我也删除了它,但得到了同样的错误。找不到对象。
  • 这意味着您在 Ubuntu 上存在配置问题。
  • @Maerlyn。请看一看。我用错误日志编辑了我的问题。

标签: php apache .htaccess mod-rewrite


【解决方案1】:

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

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

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

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

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

希望对您有所帮助。

【讨论】:

  • 它是一个简单的index.php 小写文件名。但它仍然不起作用。我已经仔细检查了情况。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-16
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 1970-01-01
    相关资源
    最近更新 更多