Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore script_name if part of URI #67

Closed
kzap opened this issue Jan 14, 2013 · 2 comments
Closed

ignore script_name if part of URI #67

kzap opened this issue Jan 14, 2013 · 2 comments

Comments

@kzap
Copy link

kzap commented Jan 14, 2013

Why not ignore $_SERVER['SCRIPT_NAME'] if its part of the URI being dispatched?

so that /index.php/ and / are the same
incase your frontend controller is frontend.php so /frontend.php/ and / are the same also

Line 87:

        // if SCRIPT_NAME is part of the REQUEST_URI, remove it from $uri since we ignore it
        if ($_SERVER['SCRIPT_NAME'] == substr($_SERVER['REQUEST_URI'], 0, strlen($_SERVER['SCRIPT_NAME']))) {
            $uri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
        }
@chriso
Copy link
Contributor

chriso commented Jan 14, 2013

Because that's just one potential way of routing.

dispatch() takes a single optional argument, $uri, which defaults to $_SERVER['REQUEST_URI'].

In your case, simply replace your dispatch() call with dispatch(substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])));

@chriso chriso closed this as completed Jan 14, 2013
@kzap
Copy link
Author

kzap commented Jan 27, 2013

k this is what i did:

// if SCRIPT_NAME is part of the REQUEST_URI, remove it from $uri since we ignore it
if ($_SERVER['SCRIPT_NAME'] == substr($_SERVER['REQUEST_URI'], 0, strlen($_SERVER['SCRIPT_NAME']))) {
        $dispatchUri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
} else {
        $dispatchUri = $_SERVER['REQUEST_URI'];
}
dispatch($dispatchUri);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants