Abhishek Gupta
Abhishek Gupta

Reputation: 6615

Forcetype in httpd.conf not working

I want to use pretty url. So I searched net and tried to use the forcetype approach.

httpd.conf:

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

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

But this doesnot work. I tried to find the solution, as suggested I also tried following:

<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>

But nothing work. I am still getting 404 error on opening http://localhost/main.

(http://localhost/main.php is working fine.) I am using xampp-linux-1.8.1 on 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

Why this is happening?

Upvotes: 1

Views: 1903

Answers (1)

Mike Brant
Mike Brant

Reputation: 71384

Just because you are trying to force the handler to be PHP5 doesn't mean that Apache will magically find a file named /main.php at /main.

You could simply rename main.php to main (while still having these handler rules in place) to make this work. Otherwise if you want to keep the .php extension on your file, you will need to look at using a rewrite directive.

Upvotes: 3

Related Questions