2 November 2012 at 11:42am
(Last edited: 2 November 2012 11:44am),
Unless you knew all the member users and hard coded each in your .htaccess, the best method is to use a custom handleAction() method to check for a member of that username (https://github.com/silverstripe/sapphire/blob/3.0/control/Controller.php#L185)
I should clarify, don't edit that file directly. You can create your custom handleAction in Page_Controller (and use parent::handleAction() to refer to the original function)
for example if the URL is: www.mydomain.com/adam
if we debug the $request or $request->latestParams(), we will never get value of "adam"
$request->latestParams() will return: Action = NULL, ID = NULL, OtherID = NULL
2 November 2012 at 10:21pm
(Last edited: 2 November 2012 10:50pm),
I've just been testing this on a site I'm building where I need to remove 'view' from 'xyz.com/projects/view/example-project', in handleAction(), the info I needed ('example-project') was found by doing:
For your example, I believe SilverStripe will think that 'adam' is the action, so you can then check for the existence of a user, then if they don't exist simply call parent::handleAction();
Sorry I've just re-read your post and you aren't getting an action returned. I don't know if it acts differently as you're trying to get the request from the home page, do you have any URL handlers set up or anything that could possibly affect it?
3 November 2012 at 4:32am
thx for your answer.
I already knew and i already re-tested your example on my project, still doesn't work.
Your answer is working on the other page except home.
- www.mydomain.com/user/adam => "URLSegment" = about, "Action" = adam
- www.mydomain.com/adam => "URLSegment" = NULL, "Action" = NULL
Can you check again on your project in the home URL?
What i want is:
- www.xyz.com/example-project, not www.xyz.com/projects/example-project
- "example-project" is dynamic value, not some of Page / Page Controller
- "projects" is Page / Page Controller and I don't need that