Welcome Guest, Not a member yet? Register   Sign In
.htaccess stuff
#3

[eluser]Fenix[/eluser]
This is for a REST API where the response content-type is requested by adding .xml or .php to the endpoint like this:
http://mysite.com/api/categories.xml
http://mysite.com/api/categories.php

The first example works fine but for the .php, my htaccess file (posted above) is looking for the real file named categories.php.

So, I still want the index.php to be removed from the url
(http://mysite.com/index.php/api/categories) but I also need it to quit catching the .php extension for /api/categories.php and other api calls like /api/images.php.

If that isn't clear... my API controller has methods like categories() and images() and users(). I also have a __construct() and a _remap() function to pull in the query string throw errors if they have missed required parameters etc...

This is my _remap() for testing. The .xml extension works fine but the .php extension doesn't work.
Code:
function _remap($method)
{
    $content_type = stristr($method, '.');
    switch($content_type)
    {
        case '.php': $this->content_type = 'php'; break;
        case '.xml': $this->content_type = 'xml'; break;
        default: $this->errors[] = 1003;
    }
    echo '$this->content_type: ' . $this->content_type . '<br/>';
    echo '$content_type: ' . $content_type;
}


Messages In This Thread
.htaccess stuff - by El Forum - 04-24-2009, 09:47 AM
.htaccess stuff - by El Forum - 04-24-2009, 12:01 PM
.htaccess stuff - by El Forum - 04-24-2009, 01:24 PM
.htaccess stuff - by El Forum - 04-24-2009, 02:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB