View previous topic :: View next topic |
Author |
Message |
JC Denton Apprentice
Joined: 16 Apr 2003 Posts: 151 Location: USA
|
Posted: Tue Apr 11, 2006 12:54 am Post subject: Apache serves files without their extension [SOLVED] |
|
|
Here's an interesting one. Have an Apache machine that's serving out a bunch of virtuals. If someone has a file, say "test.php," in their home directory; and they go to theirsite.com/test, it will serve out test.php. I think this is because of the machine's mime.types file (it has a reference to PHP files). Now on another Apache box, this one being FreeBSD with mostly a default "out of the box" config, it 404s on /test. The BSD machine has no reference to PHP stuff in it's mime.types file.
Now here's the question. How would one disable this behavior, or enable/disable it on a per-virtual basis?
Help, is as always, appreciated !
Last edited by JC Denton on Tue Apr 11, 2006 3:30 am; edited 1 time in total |
|
Back to top |
|
|
jmbsvicetto Moderator
Joined: 27 Apr 2005 Posts: 4735 Location: Angra do Heroísmo (PT)
|
Posted: Tue Apr 11, 2006 1:08 am Post subject: |
|
|
Hi.
If I understood you correctly and you want to solve your Gentoo problem, you need to enable the support for PHP. When apache gives you an php file, that means that the support for PHP has not been enabled. Besides installing and configuring PHP, you need to activate it in /etc/conf.d/apache, I think, and /etc/apache/modules.d/*php. Sorry for not giving you the exact file names, but my server with apache has died and I haven't felt up to do a reanimation. _________________ Jorge.
Your twisted, but hopefully friendly daemon.
AMD64 / x86 / Sparc Gentoo
Help answer || emwrap.sh
|
|
Back to top |
|
|
JC Denton Apprentice
Joined: 16 Apr 2003 Posts: 151 Location: USA
|
Posted: Tue Apr 11, 2006 1:10 am Post subject: |
|
|
jmbsvicetto wrote: | Hi.
If I understood you correctly and you want to solve your Gentoo problem, you need to enable the support for PHP. When apache gives you an php file, that means that the support for PHP has not been enabled. Besides installing and configuring PHP, you need to activate it in /etc/conf.d/apache, I think, and /etc/apache/modules.d/*php. Sorry for not giving you the exact file names, but my server with apache has died and I haven't felt up to do a reanimation. |
Actually, it is serving PHP out correctly. I'm just curious how to prevent it from serving /test, as well as /test.php.
EDIT- Also of note, it does this for other file types as well (e.g., HTML). |
|
Back to top |
|
|
jmbsvicetto Moderator
Joined: 27 Apr 2005 Posts: 4735 Location: Angra do Heroísmo (PT)
|
Posted: Tue Apr 11, 2006 1:45 am Post subject: |
|
|
If you want to prevent apache from serving test.php files anywhere in the tree, add the following to your apache config:
Code: | <Directory "/path/to/htdocs/*/test.php">
order deny,allow
deny from all
</Directory> |
If you allow files to be served from /home/*/hml/ also add the following:
Code: | <Directory "/home/*/html/*/test.php">
order deny,allow
deny from all
</Directory> |
Does it work? _________________ Jorge.
Your twisted, but hopefully friendly daemon.
AMD64 / x86 / Sparc Gentoo
Help answer || emwrap.sh
|
|
Back to top |
|
|
JC Denton Apprentice
Joined: 16 Apr 2003 Posts: 151 Location: USA
|
Posted: Tue Apr 11, 2006 2:04 am Post subject: |
|
|
jmbsvicetto wrote: | If you want to prevent apache from serving test.php files anywhere in the tree, add the following to your apache config:
Code: | <Directory "/path/to/htdocs/*/test.php">
order deny,allow
deny from all
</Directory> |
If you allow files to be served from /home/*/hml/ also add the following:
Code: | <Directory "/home/*/html/*/test.php">
order deny,allow
deny from all
</Directory> |
Does it work? |
No, no. Here's an example of my problem:
1) A file named test.php exists, let's say it's in ~captkirk/public_html/test.php.
2) A user goes to http://www.mysite.com/~captkirk/test.php - the file is parsed and the PHP is rendered/presented correctly.
3) A user goes to http://www.mysite.com/~captkirk/test - the file is parsed as PHP and rendered/presented.
#3 is undesirable in this case. I'd like the web server to just return a 404. |
|
Back to top |
|
|
jmbsvicetto Moderator
Joined: 27 Apr 2005 Posts: 4735 Location: Angra do Heroísmo (PT)
|
Posted: Tue Apr 11, 2006 2:21 am Post subject: |
|
|
Oh, ok. I'm sorry, but your previous reply seemed to imply that you also wanted to prevent access to any test.php file.
Did you enable the Multiviews option? _________________ Jorge.
Your twisted, but hopefully friendly daemon.
AMD64 / x86 / Sparc Gentoo
Help answer || emwrap.sh
|
|
Back to top |
|
|
JC Denton Apprentice
Joined: 16 Apr 2003 Posts: 151 Location: USA
|
Posted: Tue Apr 11, 2006 3:29 am Post subject: |
|
|
jmbsvicetto wrote: | Oh, ok. I'm sorry, but your previous reply seemed to imply that you also wanted to prevent access to any test.php file. |
Sorry. I really should preview my posts before submitting them .
jmbsvicetto wrote: | Did you enable the Multiviews option? |
That's it. It's the multiviews option serving /test. Thank you for pointing that out ! |
|
Back to top |
|
|
|