【发布时间】:2013-03-03 11:17:33
【问题描述】:
我想使用漂亮的网址。于是上网搜了一下,尝试使用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
为什么会这样?
【问题讨论】:
-
你不能使用重写有什么原因吗?
-
不,我只是在尝试这个,出现错误,所以我试图解决这个问题,但无法解决。所以寻求帮助
-
我从未使用过这种方法,但我怀疑您的文件需要是
main而不是main.php。我认为这种方法试图做的是使文件可以通过 php 执行,而无需.php扩展名 -
如果我将其设为主文件,然后尝试打开
http://localhost/main,则会下载主文件
标签: php apache lamp friendly-url httpd.conf