Welcome Guest, Not a member yet? Register   Sign In
Unable to get the links working
#1

[eluser]mayooran[/eluser]
Hi,

I'm on 1and1 host and I'm testing out the Opensource Point of Sale. Everything looks good, but when I try to add an item by using 'New Item' (i.e http://test.zimplife.com/index.php/items.../width:360)

The page is keep routing back to home page.

All the configuration is default.

$config['uri_protocol'] = 'AUTO';

While tryiing to play around it, I found that when I change the 'uri_protocol' to ORIG_PATH_INFO, it works! But the problem is, I will have an error accessing the home page.
http://test.zimplife.com/

An Error Was Encountered
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

But if I do the following:

http://test.zimplife.com/index.php/

Then it works.

Where am I going wrong?
#2

[eluser]Flemming[/eluser]
I'm not familiar with Open Source Point of Sale but your question reminds me that I've had a problem with a CI site hosted on a 1and1 server in the past. Unfortunately that site was moved to a different host and I don't remember exactly what I had done previously to get it working on 1and1 but I have a feeling it was to do with including a ? in the mod_rewrite rule.

Is it possible that if you put uri_protocol back to AUTO and then add a ? to your URL it would work?

e.g. http://test.zimplife.com/index.php?/item.../width:360

It's a long shot but I thought I'd mention it!
#3

[eluser]mayooran[/eluser]
Thank you for the tip. I have actually tested it out, it has improved.


$config['index_page'] = 'index.php?';
...
$config['uri_protocol'] = 'AUTO';

After adding ? to it, there is an improvement, but not yet how it works with uri_protocol set to ORIG_PATH_INFO


Here is the screenshot of both cases (working and not-working):

Test #1:
$config['uri_protocol'] = 'AUTO';
$config['index_page'] = 'index.php?';

http://ishashop.zimplife.com/index.php?/.../width:360

May be this can help, I noticed the following with the 1and1 site.

When I have the uri_protocol as this:

$config['uri_protocol'] = 'ORIG_PATH_INFO';

My access to home page, http://ishashop.zimplife.com/ will always results in :

Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

In order to access it, I have to do: http://ishashop.zimplife.com/index.php/

(note, if I remove the last trailing / , it'll result in the same error as above)

May be this can help someone to nail my issue.

Thanks.

Results:

#4

[eluser]InsiteFX[/eluser]
In you config.php file you need the trailing / on the end of the base_url.

#5

[eluser]mayooran[/eluser]
Thanks InsiteFX.

This is what I have tried:

Test #1:

$config['uri_protocol'] = 'ORIG_PATH_INFO';

$config['index_page'] = 'index.php?';

//$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
//$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
//$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
//$config['base_url'] .="/";

$config['base_url'] = "http://www.ishashop.zimplife.com/";

And navigating to, http://ishashop.zimplife.com , results in the familiar error,

Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.

Test #2:

Leaving everything same, except change the uri_protocol to AUTO,

Navigating to the page works. I'm able to login now and the page gets re-directed to the correct view:

1. http://www.ishashop.zimplife.com/index.php?/home

2. Now, I'm trying the problematic section, calling a form view to add a customer or add an item etc. and it still results with failure.

May be this observation can help you. When I leave everything as default, and try to get to the problematic link, the page gets loaded with 'home' view.

What's puzzling is that, when I did the test on my local server, everything worked fine. I'm also thinking if I can tackle this issue with .htaccess, tried few suggestions after reading several posts. None worked so far.

I wish I can test this out on a server other than 1and1 and see if it is the server issue or something in the code. Anyhow, I believe this can be fixed by modifying few things.

Let me continue to debug.

Thanks.
#6

[eluser]mayooran[/eluser]
Further more, I did some digging in the code,

The code I need to get working is:

<div id="title_bar">
<div id="title" class="float_left">&lt;?php echo $this->lang->line('common_list_of').' '.$this->lang->line('module_'.$controller_name); ?&gt;</div>
<div id="new_button">
&lt;?php echo anchor("$controller_name/view/-1/width:$form_width",
"<div class='big_button' left;'><span>".$this->lang->line($controller_name.'_new')."</span></div>",
array('class'=>'thickbox none','title'=>$this->lang->line($controller_name.'_new')));
?&gt;
&lt;?php echo anchor("$controller_name/excel_import/width:$form_width",
"<div class='big_button' left;'><span>Excel Import</span></div>",
array('class'=>'thickbox none','title'=>'Import Items from Excel'));
?&gt;
</div>


I tried various syntaxes on it, i.e adding ? , adding http://test.zimplife.com/index.php/ etc. none worked.

I'm not sure if I understand how CI behaves differently for this link when we have the URI_PROTOCOL changed.

#7

[eluser]CroNiX[/eluser]
I'd try using htaccess and remove index.php from the URL with mod_rewrite. It's ugly anyway. That will pass all requests to index.php so you shouldn't need it in the url and it might fix your issue and clean up the url at the same time.
#8

[eluser]mayooran[/eluser]
Thanks all. Yes, I did try to play with .htaccess as well but it didn't resolve the issue.

I ended up digging the code and I think I have found the issue. This may well be a bug with CI .

So, this what I have done to fix my issue.

So, for my application (Open Source Point of Sale), I know that I was having problem only when I played around with URI protocol. If I had it to 'AUTO' I was able to run the application but only the 'add new item' etc wasn't working. To fix it, I had to change the URI protocol to ORIG_PATH_INFO, but when I change that, my home page won't load properly, I will always have to use, <hostname url>/index.php/ << trailing slash had to be used.

So, this made me look into URI.php file shipped under ~/system/core/ directory.

Vigorously searching around this error, I came across a nice blog,

http://infopotato.com/blog/index/path_info

This author had the same experience as me and I tried to modify the URI.php by adding in the piece of code.
Code:
// Is there a PATH_INFO variable?
                        // Note: some servers seem to have trouble with getenv() so we'll test it two ways
                        $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
                        if (trim($path, '/') != '' && $path != "/".SELF)
                        {
                                $this->_set_uri_string($path);
                                return;
                        }
                   //added by Mayooran
                        elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
                                $path= trim(str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['ORIG_PATH_INFO']), '/');
                                $this->_set_uri_string($path);
                                return;
                        }

Voila!, application seems to work fine Smile I'm new to CI, so I really don't know if this is a bug in CI or the application I'm working with. Anyhow, both are missing a check for ORIG_PATH_INFO in the URI parsing. I hope this gets added.

Thanks .

-Mayooran
#9

[eluser]CroNiX[/eluser]
I'd say it's an issue with the cheap 1and1 host. Lots of people have issues with them, if you google. I've used dozens of quality servers with CI and have never had this issue.

I'd urge you to NOT alter any code in /system directory, and instead extend the core URI class and override that method.

Otherwise, each time you upgrade CI you'll have to reimplement any hacks.
#10

[eluser]mayooran[/eluser]
Thanks. I'm trying it out now. I extended URI class to MY_URI and only included the function I have modified in MY_URI.php. It doesn't seem to work.

I'll play around more.




Theme © iAndrew 2016 - Forum software by © MyBB