开发者

How to put the logged in users username in the URL?

I am making use of Codeigniter and I c开发者_StackOverflow社区urrently have this URL format setup:

http://example.com/view/

I would like to put in the logged in users username in the URL and remove the view part of the URL. The view is my controller. So I can have something that looks like this in the address bar:

http://example.com/johnny

However, I firstly tried removing the view part using my htaccess file like so:

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|css|js|swfupload|uploads|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA]

#trying to remove view??
RewriteRule ^(.*)$ view.php/$1 [QSA]

But this resulted in a 403 (forbidden) error as I have just corrupted the URL requested!

How can I best achieve this? Maybe making use of Codeigniter's routes?

Thank you all for any help.


You basically have to make a route and then routes for everything else thats not for profiles. Its kind of annoying but thats how you have to do it in CI, I may be wrong. For example:

$route['user/login'] = "user/login"
$route[':any'] = "profile/$1"; // user profile
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜