Forum Moderators: phranque

Message Too Old, No Replies

Problems with "Clean URL" system

ForceType directive in .htaccess file is not working properly

         

intrepidbunny

11:16 pm on Jul 10, 2005 (gmt 0)

10+ Year Member



Hi there. I'm having trouble creating a "clean URL" system using ForceType directives in .htaccess files.

This is the directive I put in the .htacess file in my main directory:

<Files filename>
ForceType application/x-httpd-php
</Files>

The directive successfully forces the file to be read as a PHP file when I call it without any trailing variables (http://www.website.net/filename). But when I add additional URI info (http://www.website.net/filename/variable1/variable2), I get a 404 error. (FilesMatch doesn't work either.)

Any idea why I'm encountering this problem? I've successfully used the ForceType directive in this exact same way on two other sites, using this Evolt article [evolt.org] as a guide. Not sure why it's tripping me up now.

Thanks in advance for the help.

jdMorgan

9:17 pm on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



intrepidbunny,

Welcome to WebmasterWorld!

The Filesmatch directive in the article you cite seems to be incorrect; It should read

<FilesMatch "^article">

Note that there is no end-anchor ($). If the end-anchor is included, then only a single file named "article" would be matched.

Hoever, I don't see how it would work either way. <Files> and <FilesMatch> are used to control the server based on the "basename" -- that part of the URL following the last slash in the URL. As an example, in the URL-path "/article/200206072", only "200206072" is the basename.

You might want to look into other ways of doing this. For example, you can use mod_rewrite to both re-map the URL to your content and set the MIME-type at the same time using the [T] flag of RewriteRule.

Jim

intrepidbunny

10:36 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



Jim,

Thanks so much for the fast reply. I will definitely switch over to a system using mod_rewrite.

On my other website (the one where I'm already using the ForceType directive), do you think it's possible that search engine bots are encountering errors when they try to request pages? I have had quiet a bit of trouble with proper optimization of my site's AdSense ads. I wonder if this could be the culprit.

Thanks again!

jdMorgan

1:44 am on Jul 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no way for me to tell if your old site has any problems. I'd recommend that you carefully examine your server response headers using the Server Headers [webmasterworld.com] checker in the WebmasterWorld Control Panel. You can also use a tool like WannaBrowser to pretend you are Googlebot and check your server's responses.

Jim

intrepidbunny

1:52 am on Jul 14, 2005 (gmt 0)

10+ Year Member



Thanks, Jim. I didn't know about that tool. I'm new to this, so I appreciate your patience.

I got the following response to a page using the ForceType protocol:

HTTP/1.1 200 OK
Date: Thu, 14 Jul 2005 02:00:30 GMT
Server: Apache/2.0.46 (Red Hat)
Accept-Ranges: bytes
X-Powered-By: PHP/4.3.2
Connection: close
Content-Type: text/html

It seems, then, that the Files/ForceType approach can work. The mystery is why it's working on one site but not on another, when both are on the same server.

I'm not going to bother figuring it out, though. As you recommended, I'm just going to switch to a mod_rewrite solution.

Thanks again!