CodeIgniter Forums
Basically everything fails when moving online - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Basically everything fails when moving online (/thread-1922.html)



Basically everything fails when moving online - El Forum - 07-05-2007

[eluser]Varzock[/eluser]
Hi all, newbie here *waves*

So, I have built my first CI application (gotta say I'm falling in love with this). Everything works fine when I'm working on it locally, but as soon as I make it online (uploading to a host dir), it starts falling apart... sigh.

I have quite a simple login system that checks user and pass in database and if they're correct, redirects the user to main page. Now when I login succesfully, the site goes to an infinite redirect loop. I have checked there are no loops in my models that would cause the infinite redirecting and I can't figure out what's causing it.

Let's say the site can be found at addy xxxyyyzzz.com/admin

My default route:
$route['default_controller'] = "login";

Index page:
$config['index_page'] = "";

My .htaccess file is as follows:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /xxxyyyzzz/index.php?/$1 [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

And:
$config['base_url'] = "http://www.xxxyyyzzz.com/admin/";

I have tried to search and read threads here that would help me on my way but no luck so far Sad Any help/hint is greatly appreciated. I am soon about to jump out of the window Big Grin

[EDIT: Forgot to mention I moved my app from Windows to Linux]

[EDIT: I'm terribly sorry, I just noticed I posted this in the wrong section. Any admin there, could you please move this to a correct place? Thanks Smile ]


Basically everything fails when moving online - El Forum - 07-05-2007

[eluser]Varzock[/eluser]
Update:
I now tried to change my .htaccess to this:
Code:
RewriteEngine on
RewriteRule ^$ /admin/index.php [L]
RewriteCond $1 !^(index\.php|images|css|scripts|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /admin/index.php/$1 [L]

but without luck. Now I can't access any other page than login-controller. If I try to access some other controllers (that DO exist), it throws me a 404.

Help, anybody? Confusedhut: Do I have to put the physical path anywhere or does CI take care of that?


Basically everything fails when moving online - El Forum - 07-05-2007

[eluser]Iksander[/eluser]
This one works really well for me:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Don't forget about the $base_url.


Basically everything fails when moving online - El Forum - 07-05-2007

[eluser]Varzock[/eluser]
Thanks for the tip Iksander. I have narrowed the "bug" down to this symptom: for some reason it keeps redirecting/sending me back to my login controller over and over again. I have set login controller to be my default controller though.

I check if the user has already logged in in the login controller and if she/he has, they're sent to another controller. And now it seems that because that controller "can't be found" for some reason, it sends the user back to login controller.

Does this make any sense?


Basically everything fails when moving online - El Forum - 07-06-2007

[eluser]Varzock[/eluser]
Arr this is driving me nuts (said the pirate).

I set everything correctly and I tested it really works locally. Now I moved it online again and BAM! it doesn't work even I changed the path names (xxx => yyy, you get the idea). PATH_INFO also really works on that host I tested it.

I tried to try load that simple welcome page but I get a 404:
The requested URL /yyy/index.php/welcome was not found on this server.

I guess it would be half a victory if I got a CI 404?

If anyone has got any more hints or tips, I'd greatly appreciate it. This one's is in quite a hurry to get done :/

[UPDATE: Default controller works. Just when I try to access different sections of the site by hand, it throws that 404 error. So it seems it's a .htaccess related problem. Could virtual directories and physical directories of the Linux server have anything to do with tis?]


Basically everything fails when moving online - El Forum - 07-06-2007

[eluser]Varzock[/eluser]
Some success! I removed the whole .htaccess file cause it seems that is causing the problems (or isn't supported by my host). Changed the index_page to "index.php?". Now it loads the welcome page as it should, loads login page, submits data to login controller etc. BUT! When I try to access a page xxxyyyzzz/admin/appointments/view/all it says it can't be found :/ It's a CI 404 though Wink

Any ideas?


Basically everything fails when moving online - El Forum - 07-06-2007

[eluser]stevepaperjam[/eluser]
Obviously you'd rather not have the index.php in there, but if you're in a hurry I'd be tempted to forget about removing it with htaccess.

Once you've logged in, and get the CI 404, try it with the index.php back in:

http://xxyyyzzz.com/xxxyyyzzz/index.php/admin/appointments/view/all

You'll need to sling that index_page setting in config back in as well:
Code:
$config['index_page']= "index.php";

(whups: just re-read, you've done this second bit already)


Basically everything fails when moving online - El Forum - 07-06-2007

[eluser]Varzock[/eluser]
Thanks for the tips stevepaperjam. I got everything working by removing the whole htaccess mumbojumbo.

I don't understand why it doesn't work but since I was in a really hurry, this will do for now. I asked my host if URL rewrite is supported and if Allowoverride is set as ALL and they said it is. But anyway, client is happy, I am happy ;-P Gotta check about it whenever I have more free time.


Basically everything fails when moving online - El Forum - 07-06-2007

[eluser]stevepaperjam[/eluser]
I think you're right: the problem lies in your htaccess and the server set-up with the host rather than anything on the CI side.

Your htaccess looks reasonable to me but I'm most definitely not a expert on that side of things.

The only thing that is different really is that my sites have always been served out of the root rather than a folder in the root, in the way you have. My standard htaccess just looks like everyone elses:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %(REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Anyway, glad it's all up and running.