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

无法在本地Apache服务器中打开PHP webapp。获取错误404,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我正试图开始在本地Apache服务器上使用PHP webapp(由其他人编写)。每次尝试打开项目文件夹中的任何.php文件时,都会出现错误404 我通过在其他项目中打开其他php文件来检查服务器是否正常工作,没有问题。在研究了可能的原因后,我怀疑可能是.htaccess文件引起的,但我不确定具体的问题是什么。此文件中的代码如下所示: RewriteEngine on RewriteCond %{HTTP:X-Forwarded-Proto} ^http$ RewriteRule .* https

我正试图开始在本地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>
重新编写引擎打开
重写cond%{HTTP:X-Forwarded-Proto}^HTTP$
重写规则。*https://%{HTTP_HOST}%{REQUEST_URI}[R=301,L]
选项+FollowSymlinks
选项-多视图
重新启动发动机
重写基/
重写规则^cache/(.*)/images/(.*)/images/$2[L]
重写规则^cache/(.*)/font/(.*)/font/$2[L]
重写规则^(sitemap.xml | sitemap_xml/*)-[L]
重写规则^(robots.txt | robots_txt/*)-[L]
重写规则^(sitemap.php | sitemap.php/*)-[L]
重写规则^(sitemap dom.php | sitemap dom.php/*)-[L]
重写规则^about us/cms/view/about us/1
重写规则^contact-us/cms/view/contact-us/24
重写规则^privacy policy/cms/view/privacy policy/21
重写规则^terms and conditions/cms/view/terms and conditions/20
重写规则^how WORK/cms/view/how WORK/18
重写规则^faq/cms/faq
重写规则^$public/[L]
重写规则(.*)公共/$1[L,QSA]
这是否限制了对项目目录中文件的访问


我刚刚开始使用此工具,因此非常感谢您提供的任何帮助。

根据提供的信息,您可以检查以下信息:

您正在使用https运行apache吗

在apache中的文件夹
sites enabled
上,检查ssl虚拟主机是否已启用

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

如果您想查看,可以使用telnet。我已经在端口80(apache defaut)上进行了本地尝试,以查看发生了什么:

$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
运行时的默认行为高于。要调用telnet命令,我们使用
telnet
。如果telnet在一分钟内没有响应,那么您的端口似乎没有侦听

$ telnet 127.0.0.1 443
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Network is unreachable
现在,我尝试在禁用ssl的情况下连接apache(443是默认的ssl端口),因此,返回了上面列出的错误。在这种情况下,我的
000 default ssl.conf
文件被禁用

要启用ssl配置,您可以运行
a2ensite 000 defaul ssl.conf
,其中
000 default ssl.conf
站点可用
文件夹中的我的ssl默认文件