配置Apache不重写文件+ SLASH的网址 [英] Configuring Apache to not rewrite URLs for FILE + SLASH
问题描述
我有这样的问题,即像背景/路径/文件/什么/ /如下,所有网址
变成背景/路径/ file.php /什么/是/如下
或背景/路径/ file.xml /什么/是/如下
。
I have this problem where all URLs like context/path/file/anything/that/follows
becomes context/path/file.php/anything/that/follows
or context/path/file.xml/anything/that/follows
.
我有以下重写规则:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^service/(.*)$ service.php?xyz=1 [L,QSA]
这应该映射开始服务/...
到 service.php
。现在,问题是,如果一个XML文件命名为 service.xml中
是相同的文件夹的.htaccess
中,网址被映射到该文件来代替。如果一个PHP文件存在,他们去到PHP文件。 XML文件需要precedence,也就是说,如果有两个XML文件,名为服务的PHP文件。*
目录中,XML文件被选中。
which should map any URL starting with service/...
to service.php
. Now, problem is, if an XML file named service.xml
is in the same folder as the .htaccess
, the URLs are mapped to that file instead. If a PHP file exists, they go to the PHP file. The XML file takes precedence, i.e. if there is both an XML file and a PHP file with the name service.*
in the directory, the XML file gets chosen.
我有PHP 5.3,Apache 2.X的,在Mac OS X 10.7(狮子)。这个问题并没有$ P $当我有OS X 10.6 pviously发生,所以必须在苹果提供的配置一些变化。我只是无法弄清楚。
I have PHP 5.3, Apache 2.x, on Mac OS X 10.7 (Lion). This problem did not previously occur when I had OS X 10.6, So there must be some changes in the configurations provided by Apple. I just cannot figure out what.
有没有一种方法,我可以禁用此的 functoinality 的?
Is there a way I could disable this functoinality?
还是我完全偏离轨道,并donig一些愚蠢的事?
Or am I entirely off-track, and donig something stupid?
顺便说一句,这并不涉及到mod_rewrite的,启用或禁用它,或删除从的.htaccess
改变任何东西重写规则。该网址服务/我的/参数
仍然指向 service.xml中/我的/参数
,即使mod_rewrite的被禁用。
BTW, this does not relate to mod_rewrite, as enabling or disabling it, or removing the rewrite rule from the .htaccess
changes anything. The URL service/my/parameter
still points to service.xml/my/parameter
, even if mod_rewrite is disabled.
现在,我刚拍摄的查询串出的url,并手动解析它的PHP文件中。但我知道,是不是这样做的正确方法。
For now, I have just taken the query string out of the url, and parsed it manually inside the PHP file. But I know that is not the right way to do this.
推荐答案
这似乎是的启用多视图选项。
尝试添加选项-MultiViews
在<目录方式>
部分(或的.htaccess)
Try to add Options -MultiViews
in the <Directory>
section (or .htaccess).
这篇关于配置Apache不重写文件+ SLASH的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!