>
>> What does your Auth config look like?
> What do you mean? What info on Auth config should i post?
You need to configure Auth in AppController::beforeFilter()
http://book.cakephp.org/view/1250/Authentication
>> What does your login have in it?
> users_controller.php has this function. nothing more than what the
> default cakePHP login has. asks for username and password.
>
> function login() {
> // http://book.cakephp.org/view/643/Preparing-to-Add-Auth
> // Authenticate Magic
>
> // http://book.cakephp.org/view/649/Logging-in
> if ($this->Session->read('Auth.User')) {
> $this->Session->setFlash('You are logged in!');
> $this->redirect('/', null, false);
> }
> //
> }
Try commenting all of that out for now. Just leave login() as an empty method.
>> Are you using mod_rewrite?
> I have these 3 .htaccess and 3 index.php files
> ####
> /var/www/web2/web/.htaccess
>
> <IfModule mod_rewrite.c>
> RewriteEngine On
> RewriteRule ^$ app/webroot/ [L]
> RewriteRule (.*) app/webroot/$1 [L]
> </IfModule>
>
> ####
> /var/www/web2/web/index.php
> contains :
> define('APP_DIR', 'app');
> define('WEBROOT_DIR', 'webroot');
> define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
>
> define('ROOT', dirname(__FILE__));
> // should above be : define('ROOT','/var/www/web2/web');
__FILE__ means the current filename, and dirname() returns the
directory part of the path. So it amounts to the same thing. Better to
leave it as is.
> ####
> /var/www/web2/web/app/.htaccess
>
> <IfModule mod_rewrite.c>
> RewriteEngine On
> RewriteRule ^$ webroot/ [L]
> RewriteRule (.*) webroot/$1 [L]
> </IfModule>
>
> /var/www/web2/web/app/index.php
> require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
>
>
> ####
> /var/www/web2/web/app/webroot/.htaccess
>
> <IfModule mod_rewrite.c>
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
> </IfModule>
>
> ####
> /var/www/web2/web/app/webroot/index.php
> contains :
> define('ROOT', '/var/www/web2/web');
> define('APP_DIR', 'app');
> define('CAKE_CORE_INCLUDE_PATH', '/var/www/web2/web');
>
>
>> Have you checked what headers the server is returning?
> How is this done?
The easiest way is probably with the Firebug or LiveHTTPHeaders
plugins for Firefox.
>> Also, why do you have app in the URL in the first place?
>> Why not set app to be the webserver's root?
> How do I do this?
Actually, I meant, app/webroot, but anyway ...
It depends on what your DocumentRoot is set to for Apache. It looks
like yours is:
/var/www/web2/web/
But, because you do have the .htaccess file in that dir, you shouldn't
need to supply 'app/' in the URL to get a proper Cake request from
Apache. When you request http://abc.domain.com/ Apache should look at
the .htaccess file in that dir and following the rewrite rule pointing
it instead to app/webroot/index.php. It should do the same if
requesting http://abc.domain.com/app (notice those two .htaccess files
both point the request to app/webroot/index.php)
If you can edit your httpd.conf or virtual host configs, the best
thing to do is to set DocumentRoot to:
/var/www/web2/web/app/webroot
If you can do that, for performance benefits, you should also remove
(or rename) all of the .htaccess files and add both "AllowOverride
None" (to tell Apache to ignore .htaccess) and the contents of
app/webroot/.htaccess to the <Directory> block in your Apache config.
Putting it all together:
DocumentRoot /var/www/web2/web/app/webroot
<Directory "/var/www/web2/web/app/webroot">
AllowOverride None
DirectoryIndex index.php
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
</Directory>
(There's other stuff you'll need that has nothing to do with this
subject, though.)
Now, any request to http://abc.domain.com/ will go to index.php by
default. Anything else you place under webroot (javascript, css, html,
images, whatever) will be served normally, as long as Apache can see
it.
The only downside to doing this is if you've got other stuff in your
DocumentRoot (stats, logs, other shared hosting stuff). If that's the
case, you can deal with it through addition of some RewriteRules in
your config, but that's beyond the scope of this post (I have to get
back to work).
(hint: if possible, set up subdomains for your stats, PHPMySQLAdmin, etc.)
Now, whether that will fix your problem, I don't know. It's been years
since I really got my hands dirty with mod_rewrite and I couldn't say
what's going on with your situation. Is this a shared hosting
environment? I'm wondering if there's something else configured that's
hidden from you. You mentioned that you're only seeing this upon
login. But, what about if you call redirect() in some other action?
Try this in one of your controllers, eg. Posts:
function beforeFilter()
{
$this->Auth->allow(array('foo', 'bar'));
}
function foo()
{
$this->redirect(array('controller' => 'posts', 'action' => 'bar'));
}
function bar()
{
die('ok');
}
request: /posts/foo
If you see the same problem, you'll know that it's not Auth.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment