简体   繁体   中英

Apache Server Downloads .php Files in Subdirectories

So I've been searching all over the internet for a solution to my problem and I've tried just about everything I could find, but still nothing is working.

My problem is that when I open a .php file in chromium by using:

localhost/filename.php

it works fine. If I put the file in a subdirectory and access it as such:

localhost/subdirectory/filename.php

it works fine as well. The problem comes when I try to access the .php file in the subdirectory from another file. For example I have an entire project located under:

var/www/test

with the index.html sitting in that folder and then the .php scripts in a folder located at:

var/www/test/php_scripts

In the HMTL file there is a form that sends the form data to one of said .php scripts and when I click the submit button it downloads the .php script instead of navigating to it and executing in the browser.

I tried moving the script into the "test" folder so it was with the index.html file and that didn't fix anything. If I place everything in:

var/www

it all works fine. But I don't want to do that because then I have to deal with a cluttered mess of files which no one likes doing...

I did search for the past couple hours all over stack exchange and other sites and couldn't find anything that worked. If this is a duplicate question then please point me in the direction of the answer, if not, hopefully one of you jedi coders can solve my headache.

Thanks,

Zak

It sounds like you need to look at the action part of your html form.

Make sure that the action starts with a /

Example

<form action="/php_scripts/script_name.php>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM