I am very new to the Yii framework and I want to create my first website with it.
A user can register on my website and create a user name. After the registration process he should be able to access his own page(with custom css) with the url:
where "username" stands for his username he inserted in the user registration form. As far as I know I have to add a new route for this after all other routes.
Can somebody let me know how the route for this will be implemented? I am also a little bit concerned that I could create a security issue when I treat them false.
Further I don’t know how to prevent the user don’t type in some keywords like “admin” which I need for my admin module url www.domain.com/admin for his username.
This is quite simple, you will need a rule like this in the url manager:
'<username:[a-zA-Z0-9_-]+>'=>'user/profile',
//$_GET['username'] will return the value if it is a match.
But you need to have in mind that, you will have some issues with the other pages of the website, therefore, you need to pass a url rewrite rule for each of them and these rules must come before the above rule, so you would have:
[... all other rules here...]
'<username:[a-zA-Z0-9_-]+>'=>'user/profile',
Now, regarding the prevention of certain names usage, this is also simple,
In the registration process, define a array (or load a database table having forbidden names) and if the username choosen by the user matches one of the forbidden ones, just let the user know this and let him take another username.
where the last rule is reponsible to forward www.mydomain.com/test to pass page param to pagecontroller with action show. the problem I now have is that if I go to other urls like www.domain.com/gii he is routing to my pagecontroller. am i doing something wrong here, i thought if i add this as the last route it should pick than the available one.