繁体   English   中英

httpd.conf中的强制类型不起作用

[英]Forcetype in httpd.conf not working

我想使用漂亮的网址。 因此我搜索了net并尝试使用forcetype方法。

httpd.conf:

<Files "main">
    ForceType application/x-httpd-php
</Files>

ls htdocs/
favicon.ico  index.php  main.php  webalizer  xampp

但这是行不通的。 我尝试找到解决方案,如建议的那样,我还尝试了以下操作:

<Files "main">
    ForceType application/x-httpd-php5
</Files>

<Files "main">
    ForceType application/x-httpd-php
    SetHandler application/x-httpd-php
</Files>

<Files "main">
    ForceType application/x-httpd-php5
    SetHandler application/x-httpd-php5
</Files>

但是没有任何作用。 我在打开http://localhost/main时仍然出现404 error

http://localhost/main.php正常工作。)我在Linux abhi-me 3.0.0-31-generic #49-Ubuntu SMP Tue Feb 19 20:02:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux上使用xampp-linux-1.8.1 Linux abhi-me 3.0.0-31-generic #49-Ubuntu SMP Tue Feb 19 20:02:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

为什么会这样呢?

仅仅因为您试图将处理程序强制为PHP5并不意味着Apache会在/main处神奇地找到一个名为/main.php的文件。

您可以简单地将main.php重命名为main (同时仍保留这些处理程序规则)以完成此工作。 否则,如果要在.php保留.php扩展名,则需要使用重写指令来进行检查。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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