The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

slim doesn`t match route

t.engels's Avatar

t.engels

29 May, 2012 01:53 PM

Hi,

i am new to slim and have a little problem...

i have code like

jquery:
` $.ajax({

     type: "GET",
     dataType : 'json',
     url: 'https://url.de/project/api/login',
     success: function.....

slim index: $app = new Slim(); $app->get('/login', 'loginUser'); $app->get('/', 'returnTrue'); ...

functions..
... $app->run(); `

the filepath is correct but slim allwas uses the '/' route instead of the '/login' route..
I tried several things but cant get a solution....
As you can see i have HTTPS but i cant imagine that this is a problem.

htaccess:
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L]

  1. Support Staff 1 Posted by Andrew Smith on 29 May, 2012 01:59 PM

    Andrew Smith's Avatar

    Is your codebase on Github or somewhere I can take a look at it? are your Slim files in directory project/api/ ? do you have a

    RewriteBase
    

    in your .htaccess file?

  2. 2 Posted by t.engels on 30 May, 2012 06:21 AM

    t.engels's Avatar

    Hi,

    sorry my code is not on free te look at.

    My project directory is like https://url.de/projekt/
    The Slim api dir is directly https://url.de/projekt/Slim/
    In this directory I have the .htaccess with

    # RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L]

    In the index.php of Slim/ i got:
    require 'Slim/Slim.php'; $app = new Slim(); $app->get('/login/:user/:pw', 'loginUser'); $app->get('/', 'someFunction');

    Ajax call :
    `$.ajax({

         type: "GET",
         dataType : 'json',
         url: 'https://url.de/project/api/#login/'+$('#user').val()+'/'+MD5($('#password').val()),
    

    success: function(data) {alert('succez'+JSON.stringify(data)+"end")},
    });`

    I try to ajax the url from https://url.de/projekt/js/view/home/login.js (with backbone.js)
    The Ajax call is ok so i dont think it`s the .htacces that fails, but it always returns the result of "someFunction" instead of loginUser

    I hope this helps.

  3. 3 Posted by t.engels on 31 May, 2012 07:25 AM

    t.engels's Avatar

    Andrew thanks for replying, i got the solution in between.
    Simple solution: Our sysadmin put on mod_rewrite on http but not on https ...d`oh !!

  4. t.engels closed this discussion on 31 May, 2012 07:25 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac