1

My routes.cfg:

GET|POST / = IndexController->index, 60
GET|POST /auth/@action = AuthController->@action

If I go to the url http://localhost/powers/ it properly instantiates F3 and then reroutes to the IndexController->index as referenced above. From there it executes the following line:

$this->fw->reroute('/auth/login?redirect='.$path);

changing the url in the browser to http://localhost/powers/auth/login?redirect=/

Yet it fails to load with a 404. The @action is equal to 'login' which is referenced in the routes.cfg and the function login is accessible. This issue only happens when I run locally, not in production.

My .htaccess file:

<FilesMatch \.php\.txt$>
    RemoveHandler .php
    ForceType text/plain
</FilesMatch>
RewriteEngine On
RewriteBase /powers/
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /powers/app/index.php [L,QSA]

Any help would be great, thanks.

Jeremy
  • 3,620
  • 9
  • 43
  • 75
  • If I understand you well, the issue is not with rerouting but with `/auth/login` failing to load. Have you checked your [.htaccess](http://fatfreeframework.com/routing-engine#sample-apache-configuration), especially the `RewriteBase` directive? – xfra35 Apr 28 '16 at 19:19
  • I have not, I will look into that – Jeremy Apr 28 '16 at 19:26
  • I attempted to follow http://stackoverflow.com/questions/4576851/simple-problem-with-mod-rewrite-in-the-fat-free-framework with no luck. I will add my .htaccess file to my question. – Jeremy Apr 28 '16 at 20:02
  • Don't you have a typo on the last line? Should be either `/powers/index.php` or `index.php`. Also make sure that `FilesMatch` doesn't interfere. – xfra35 Apr 28 '16 at 20:28
  • @xfra35 I tried that as well (even removed the `FilesMatch` just in case) – Jeremy Apr 28 '16 at 20:32
  • 1
    So the issue is not with rerouting but with `http://localhost/powers/auth/login` throwing a 404 right? Then for some reason, the rewriting doesn't occur, which explains that `/` is the only route working. To debug that, you'd better enable `mod_rewrite` [logging](http://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging). If rewriting is happening, you should see something like `internal redirect with /path/to/index.php [INTERNAL REDIRECT]`. If it fails, you should get a clue. – xfra35 Apr 28 '16 at 20:47
  • Thanks, this seems to have lead me to the solution (somethings are still not loading but at least it is not a 404). After following those steps I found out my .htaccess file was not being picked up so I had to move it to the root directory. – Jeremy Apr 28 '16 at 21:24

0 Answers0