无法在本地Apache服务器中打开PHP webapp。收到错误404

我正在尝试在本地Apache服务器上开始使用PHP Webapp(由其他人编写)。每次我尝试打开项目文件夹中的任何.php文件时,都会收到错误404。

我通过打开其他项目中的其他php文件来检查服务器是否在工作,那里没有问题。在研究了可能的原因之后,我怀疑它可能是.htaccess文件,但是我不确定具体的问题是什么。该文件中的代码如下:

RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    Options -Multiviews
    RewriteEngine On
    RewriteBase /
    RewriteRule ^cache/(.*)/images/(.*) /images/$2 [L]
    RewriteRule ^cache/(.*)/fonts/(.*) /fonts/$2 [L]        
    RewriteRule ^(sitemap.xml|sitemap_xml/*) - [L]
    RewriteRule ^(robots.txt|robots_txt/*) - [L]
    RewriteRule ^(sitemap.php|sitemap.php/*) - [L]
    RewriteRule ^(sitemap-dom.php|sitemap-dom.php/*) - [L]
        RewriteRule ^about-us /cms/view/about-us/1
        RewriteRule ^contact-us /cms/view/contact-us/24
        RewriteRule ^privacy-policy /cms/view/privacy-policy/21
        RewriteRule ^terms-and-conditions /cms/view/terms-and-conditions/20
        RewriteRule ^how-it-works /cms/view/how-it-works/18
        RewriteRule ^faq /cms/faq
    RewriteRule    ^$ public/    [L]
    RewriteRule    (.*) public/$1    [L,QSA]
 </IfModule>

这是否限制了对项目目录中文件的任何访问?

我刚刚开始使用它,因此,您所能提供的任何帮助将不胜感激。

sddpy 回答:无法在本地Apache服务器中打开PHP webapp。收到错误404

使用提供的信息,您可以检查以下假设:

您是否通过https运行Apache?

在您的Apache的文件夹sites-enabled中,检查ssl虚拟主机是否已启用。

如果未运行,则可能是.htaccess文件重定向到https,而在443端口上运行,第2行和第3行将所有http请求重定向到https请求。 / p>

如果要检查,可以使用telnet。我已经在80端口(默认为defaut)上尝试了本地操作,以查看会发生什么情况:

$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

运行时的默认行为如上。要校准telnet命令,我们使用telnet <address> <port>。如果telnet保持一分钟无响应,则表明您的端口未在监听

$ telnet 127.0.0.1 443
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Network is unreachable

现在,我尝试禁用ssl(默认的SSL端口443)连接我的apache,因此,上面列出的错误已返回。在这种情况下,我的000-default-ssl.conf文件被禁用了

要启用ssl配置,您可以运行a2ensite 000-defaul-ssl.conf,其中000-default-ssl.conf是我的sites-available文件夹中的ssl默认文件。

本文链接:https://www.f2er.com/3163290.html

大家都在问