[SOLVED] How to make console.php inaccessible from browser?

Hello everyone.

Well this is not my first post here, but I’m still a newbie, and it’s certainly the first topic I start.

I’ve been looking around and I am not able to find a hint to this situation:


[*]I set up my cron and it works correctly. I followed this kind of approach

[*]The cronjob (following the template of [font="Courier New"]/full/path/to/php /full/path/to/bugitor/console.php your_command[/font]) works perfectly

[*]But when I try to access http://myhost.ma/console.php in the browser (just to test, because I don’t need that), I have a blank page with this message

like the one in this post

[*]For the moment, I’m using in console.php the same config file as the Web application, where the CFileLogRoute is active

[*]For the moment, the cronjobs are not silent (no [font=“Courier New”]>> /dev/null 2>&1[/font]). I doubt it changes anything (I haven’t tried), but hey I prefer to underline that :slight_smile:

[*]I haven’t put getHelp() methods in my command files


The question(s) is(are):

  • is it prone to any security breaches?

  • Is there a parameter in Yii I’m missing?

  • Or should I deal with it through .htaccess to redirect browser to some othe blank file when trying to access console.php?

  • I’m not even sure that redirecting in .htaccess would not affect crons as well.

Couple of days ago I raised the same question and got a very nice solution. I encourage you to use it:


Let me know if questions

Looks like a bug, doesn’t it?

A console app shouldn’t run in a browser.

Yep it would be great if you guys fix it :)

Well thanks bettor for your hint. I had indeed seen your post but thought it was something else :( as I saw you talking about cron.php… my bad.

So, what’s the final steps please? There’s also this post which says to put the command file in protected/commands. But in yours, you’ve been told to put in protected/console. And should I forget about my webroot/console.php, or put it somewhere? Will config/main.php be enough, or should there be config/console.php?

Anyway, about it being a bug, that’s what I wasn’t sure of, thus my post :slight_smile: Who’s gonna report it?

@bennouna: go ahead and use yiic cronCommand.php approach. That would mean create your cron job and upload it to protected/commands and then call it like protected/yiic cronCommand.php

Let me know if you have any difficulties

Great @bettor and many thanks. I removed my console.php, and used yiic. It worked only after I checked my protected/yiic.php to change $yiic path and $config filename.

Question solved :slight_smile: