Welcome Guest, Not a member yet? Register   Sign In
Problem with double slash in URL
#1

[eluser]koniczynek[/eluser]
Hello All,

I tried searching myself but failed (both Google and this forum gave me no answer to my problem).

After upgrading from WAMP 2.2 to 2.4 my Code Igniter instance stopped working. Both WAMP server instances was out-of-the-box setups.

I am running CI 2.1.0.

And now for the "not working part" - when there is a double slash before module name in the URL I get an error: Fatal error: Class 'CI_Controller' not found

For example: http://localhost/my_application//my_module/my_method

This worked today before upgrade, now it does not and I seriously can't figure out what to do with it. If someone has any idea on why this stopped working, please let me know.

Also: removing double slashes with rewrite rules - no-no as I use POST and rewrite will trigger 301 http code which will redirect me to GET and loose all my posted data in the process.

Kind regards,
Confused Mike.
#2

[eluser]CroNiX[/eluser]
I'd figure out what is causing the extra slash rather than trying to make it work with it included. It shouldn't be there.
#3

[eluser]koniczynek[/eluser]
Hi,

Extra slash is caused by {{ site_url }} that contains it and me using construction like this:

{{ site_url() }} + "/my_module/my_method" which in return is translated to "http://localhost/my_application//my_module/my_method".

Changing this would mean going through the whole large application and correcting this in places it's causing problems and right now I do not have time for this, that's why I would like to make it work as it previously have.

Regards,
M.
#4

[eluser]CroNiX[/eluser]
It's not hard to do a file search for "/

I'm sorry it will take you a while to go through your code to fix your errors, but it is the proper thing to do. Your code is flawed, despite that it "worked" before. Fix the problem, not the symptoms. This can lead to other problems as well depending on the browser used, and as you can see, when you upgrade your services. I'll bet you could have fixed them properly in the time you've spent trying to work around the problem. Just sayin...
#5

[eluser]koniczynek[/eluser]
I forgot to mention that this code works on a number of systems (linux, windows) right now the only place it does not work is my WAMP box.

Of course your suggestion is valid, but I hoped for a faster resolution because of time pressure.
#6

[eluser]koniczynek[/eluser]
Just to let you know I identified cause of this - PHP version. In PHP < 5.4 everything works, in PHP >= 5.4 it does not. Being more specific there is parse_url() function that behaves differently in those versions. You can test it here:

http://sandbox.onlinephpfunctions.com/

Try this code:

Code:
echo parse_url("//module_name/parameteres/here", PHP_URL_PATH);

And see how output is different.

PHP < 5.4 : //module_name/parameteres/here
PHP > 5.4 : /parameteres/here

I checked on php.net for any comments in documentation but there are none.




Theme © iAndrew 2016 - Forum software by © MyBB