安装 WAMP 后,通过浏览器访问时会下载 php 文件而不是运行 [英] After having installed WAMP, php files download when accessed through the browser instead of being run

查看:54
本文介绍了安装 WAMP 后,通过浏览器访问时会下载 php 文件而不是运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装 WAMP 后,我成功访问了 http://localhost/index.php 这是 WAMP 索引页.所以 Apache 工作正常.

After having installed WAMP, I successfully accessed http://localhost/index.php which is the WAMP index page. So Apache is working properly.

然后我将我的代码复制到 C:/wamp/www/mycode/并尝试通过 http:/访问它/localhost/mycode/somepage.php.此时会下载脚本,而不是运行脚本.

I then copied my code into C:/wamp/www/mycode/ and tried to access it through http://localhost/mycode/somepage.php. Instead of running the script it downloads it at this point.

将文件移动到 C:/wamp/www/somepage.php 工作得很好,所以出于某种原因,它不允许我在根文件夹的子目录中放置文件.

Moving the files to C:/wamp/www/somepage.php works perfectly fine though, so for some reason it won't allow me to have files in a subdirectory of the root folder.

我的 httpd.conf 文件包括以下类型和处理程序:

My httpd.conf file includes the following types and handlers:

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3

AddHandler application/x-httpd-php .php .phtml
AddHandler x-httpd-php .php .phtml

我浏览了大量相关问题,但没有一个能够解决我的问题.问题一定是由于某种原因我无法在根文件夹的子目录中运行我的 php 文件.另外,我试过在所述子目录中运行 html 文件,它们工作正常.

I have browsed through a large number of related problems but none have been able to solve my problem. The problem must be that for some reason I cannot run my php files in a subdirectory of the root folder. Also, I have tried running html files in said subdirectory and they work fine.

推荐答案

我遇到了这个问题,如果您实际上从未使用过服务器配置设置,那么您的 .htaccess 文件中有 90% 的问题是

I had this problem and if you actually never played with your server configuration settings, then your problem is 90% in your .htaccess file

检查您的 http://localhost/mycode/.htaccess 文件或尝试在没有它的情况下运行您的网站.

Check your http://localhost/mycode/.htaccess file or try running your site without it.

这篇关于安装 WAMP 后,通过浏览器访问时会下载 php 文件而不是运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆