Welcome Guest, Not a member yet? Register   Sign In
Remove index.php using PATH_INFO
#1

[eluser]Brandon Beasley[/eluser]
Is it possible to remove index.php from URLs with PATH_INFO enabled as uri protocol?

I can make it work by changing uri protocol to REQUEST_URI and using HTACCESS files but that breaks my Twitter API code which requires PATH_INFO.

Should I try to fix the Twitter API code to work with REQUEST_URI or is there way to make codeigniter do this?

Or is there a way to use both PATH_INFO and REQUEST_URI in one application?
#2

[eluser]WanWizard[/eluser]
I don't understand this question.

Both are variables set by the webserver in the $_SERVER array. The CI URI library uses this information to extract the URI segments from the request.

It has nothing to do with removing the index.php. Furthermore, the information isn't altered by the URI library, so I don't see why the method used by CI will impact something else.

I guess the issue is that you use a third party twitter API that is not CI aware, and can't deal with the fact the you have a .htaccess that removes index.php from the URI. So that is what you should fix.
#3

[eluser]Brandon Beasley[/eluser]
WanWizard ->

Example:

Remove index.php while using Elliot Haughin's Twitter Codeigniter library.

http://www.haughin.com/2009/05/01/twitte...auth-love/
#4

[eluser]Brandon Beasley[/eluser]
Wanwizard...

How would you remove index.php from an application url without changing the following setting?

$config['uri_protocol']= "PATH_INFO";
#5

[eluser]WanWizard[/eluser]
Looking at the twitter library, I can't find a reference to any server variable.

I do find it in the example 'home' controller, where $_SERVER['REQUEST_URI'] is referenced directly, but only to extract the URL path from the URI, which should be available via the URI library as well...
#6

[eluser]Brandon Beasley[/eluser]
The URL that twitter calls back to is coming up with 404's:

http://testsite.com/oauth/confirm?oauth_...ahblahblah

also tried:

http://testsite.com/index.php/oauth/conf...ahblahblah

Here is what I have setup in config.php:


$config['uri_protocol'] = "REQUEST_URI";

$config['enable_query_strings'] = TRUE;

$config['permitted_uri_chars'] = 'a-z? 0-9&=~%.:_\-';


Is it possible to set just the oauth.php controller to use $config['uri_protocol']= "PATH_INFO"

Of course if I change the config.php setting back to $config['uri_protocol']= "PATH_INFO" twitter calls back correctly but I can't remove index.php from URLs.

Thanks for the help WanWiz.

Edit: Could I make a custom route to handle this? or am I still missing something?
#7

[eluser]WanWizard[/eluser]
Do you have a controller called oauth? With a method called confirm()?

Did you install the MY_Input library extension in your application libraries folder? Because that contains the code that hacks the input library so that the query string is not removed. No need to change any configuration. This is absolutely required.

And set the uri_protocol to AUTO. In most cases it's the best option (you're not using Windows are you?). I can't figure out why this should be set to REQUEST_URI. This config setting is only used in the uri library, and has no influence on the way the input library processes the query string.
#8

[eluser]Brandon Beasley[/eluser]
-- I have a controller name "oauth.php" with method called "confirm" :

function confirm() {

$consumer_key = 'XXXXXXXXXXXXXXXXXXXX';
$consumer_key_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

$twitterObj = new EpiTwitter($consumer_key, $consumer_key_secret);

$twitterObj->setToken($_GET['oauth_token']);
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);

// save to cookies
$data = array (
'access_token' => $token->oauth_token,
'access_token_secret' => $token->oauth_token_secret
);

$this->session->set_userdata('twitter_oauth_tokens', $data);

}


-- MY_Input.php is installed in application/libraries.

-- When I set uri_protocol to AUTO, I get 404's back when trying to access any of my pages other than the default controller and the twitter callback address is correct but I receive 404.

It's bugging me that twitter only works with PATH_INFO enabled in config.php

And Removing index.php from URL only works with REQUEST_URI enabled in config.php

Thanks for your help.
#9

[eluser]WanWizard[/eluser]
Can you do a
Code:
var_dump($_SERVER);
and post the result here (or send it via PM if you prefer)?

Replace sensitive info with 'xxxxx' if you want to, but don't remove any lines. I'll see if I can recreate your problem here.
#10

[eluser]Brandon Beasley[/eluser]
Sent PM. Thanks for your help.

Everyone: (I will update this thread if solution is found)




Theme © iAndrew 2016 - Forum software by © MyBB