logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Problems with ForceType
Author
jgp4



Joined: 16 Aug 2006
Posts: 4

PostPosted: Wed 16 Aug '06 19:59    Post subject: Problems with ForceType Reply with quote

I'm having some problems with ForceType in my .htaccess file.

I'm trying to do a PHP version of mod_rewrite of sorts, as outlined in this tutorial
http://www.tutorio.com/tutorial/php-alternative-to-mod-rewrite-for-se-friendly-urls

but it's not working - allow me to explain:-

I have a php file called home.php, and I want this to be loaded when I go to http://localhost/home/type/name (where type and name are to do with loading templates and content). Override all is on in httpd.conf, and in my .htaccess file I have:

<FilesMatch "^home$">
ForceType application/x-httpd-php
</FilesMatch>

as it says I should in the tutorial, but the server looks for a file called 'home' to process as PHP, rather than opening home.php.

Is this a problem with my server setup or do I need to add something extra to the FilesMatch?

Is there anyway to tell the server to load home.php?

Any help is greatly appreciated.
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Wed 16 Aug '06 20:15    Post subject: Reply with quote

You said : Override all is on ....
I supose you mean: AllowOverride All .

Looks like Apache is not reading .htaccess.
Be sure that AllowOverride All is in the good place.
Back to top
jgp4



Joined: 16 Aug 2006
Posts: 4

PostPosted: Wed 16 Aug '06 20:25    Post subject: It's all working Reply with quote

Yes thats what I meant.

.htaccess is working, if I say

<FilesMatch "^home.php$">
ForceType text/html
</FilesMatch>

then home.php displays the page plus all of the code, so it is working.

The apache error says

[client 127.0.0.1] script 'C:/Program Files/Apache Group/Apache2/htdocs/home' not found or unable to stat

thanks
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Wed 16 Aug '06 20:54    Post subject: Reply with quote

I am puzzled. Your php is working, .htaccess is read and the filematch looks fine.

When you rename home.php to just home, what happens.

When I read the ASF docu, it says:
"For example, if you had a directory full of GIF files, but did not want to label them all with .gif"

You can read that as: name the file xxx instead xxx.gif.

Steffen
Back to top
jgp4



Joined: 16 Aug 2006
Posts: 4

PostPosted: Wed 16 Aug '06 20:58    Post subject: Reply with quote

When I rename home.php to just home it works fine. I'm pretty sure the server is looking for a file called 'home' with no extension - but i thought it should look for a .php file as that is what the mime type is set to.

V. confused
Back to top
jgp4



Joined: 16 Aug 2006
Posts: 4

PostPosted: Wed 16 Aug '06 21:00    Post subject: Reply with quote

do you think i should just remove the extension on all my php files? Or would that present a security issue?
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Wed 16 Aug '06 22:44    Post subject: Reply with quote

Indeed, it looks likes it works that way, it is changing the type and not the extension.

Thanks for the posts, I learned again.

Steffen
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 17 Aug '06 9:33    Post subject: Reply with quote

You can set in .htaccess file in that folder
Code:

php_admin_value xbithack 1

Than will any file with any extention parsed (excluded .htaccess, .htpasswd, README*, HEADER*)
Back to top


Reply to topic   Topic: Problems with ForceType View previous topic :: View next topic
Post new topic   Forum Index -> Apache