没有扩展名的PHP文件 [英] PHP files without extension

查看:107
本文介绍了没有扩展名的PHP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何设置Apache在发送响应之前将任何扩展名发送到PHP的文件。有没有办法这样做没有扩展名的文件

无论如何?我不希望所有*文件都被PHP解析,但只有那些

没有扩展名(当然,还有一些选定的扩展名)。


Berislav


-

如果互联网是马克斯兄弟电影,网络,电子邮件和IRC是

Groucho,Chico和Harpo,然后Usenet是Zeppo。

解决方案

Berislav Lopac< be ********* ***@dimedia.hr>写道:

我知道如何设置Apache在发送响应之前向PHP发送任何扩展名的文件。对于没有扩展名的文件有没有办法呢?我不希望所有*文件都被PHP解析,但只有那些没有扩展名的文件(当然还有一些选定的扩展名)。




也许你应该看看MultiViews。这使得你可以在没有扩展名的情况下编写URL

,并让Apache猜测实际上应该使用什么文件

。例如, http://example.com/foo 将被评估为
< a rel =nofollowhref =http://example.com/foo.phptarget =_ blank> http://example.com/foo.php 如果存在或 http://example.com/foo.html

代替.. 。


-


Daniel Tryba


On Tue ,2004年8月31日12:03:12 +0200,Berislav Lopac

< be ************ @ dimedia.hr>写道:

我知道如何设置Apache在发送响应之前向PHP发送带有任何扩展名的文件。对于没有扩展名的文件有没有办法呢?我不希望所有*文件都被PHP解析,但只有那些没有扩展名的文件(当然还有一些选定的扩展名)。

Berislav



如果这是在Unix机器上,只是删除扩展并提供你

在顶部有''<?php'',文件应该被解析为PHP文件。


与windoze不同,Unix并不愚蠢地依赖文件扩展名来告诉操作系统文件是什么。


另一种方法是在Apache中使用mod_rewrite:

RewriteRule / ^(files | you | wish | to | parse | as | php)


/

I know how to set Apache to send files with any extension to PHP before
sending a response. Is there a way to do so for files with no extension
whatsoever? I don''t want *all* files to be parsed by PHP, but only those
without extension (and, of course, with some selected extensions).

Berislav

--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.

解决方案

Berislav Lopac <be************@dimedia.hr> wrote:

I know how to set Apache to send files with any extension to PHP before
sending a response. Is there a way to do so for files with no extension
whatsoever? I don''t want *all* files to be parsed by PHP, but only those
without extension (and, of course, with some selected extensions).



Maybe you should take a look at MultiViews. This lets you write URLs
without extension and let Apache guess what file actually should be
used. http://example.com/foo will for example be evaluated to
http://example.com/foo.php if it exists or http://example.com/foo.html
instead...

--

Daniel Tryba


On Tue, 31 Aug 2004 12:03:12 +0200, "Berislav Lopac"
<be************@dimedia.hr> wrote:

I know how to set Apache to send files with any extension to PHP before
sending a response. Is there a way to do so for files with no extension
whatsoever? I don''t want *all* files to be parsed by PHP, but only those
without extension (and, of course, with some selected extensions).

Berislav


If this is on a Unix box, just dropping the extension and providing you
have ''<?php'' at the top, the files should be parsed as PHP files.

Unlike windoze, Unix doesn''t stupidly rely on the file extension to tell
the OS what the file is.

The other way would be to use mod_rewrite in Apache:
RewriteRule /^(files|you|wish|to|parse|as|php)


/


这篇关于没有扩展名的PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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