Welcome Guest, Not a member yet? Register   Sign In
Rewrite URL with htaccess while using original URI
#1

[eluser]RJ[/eluser]
I would like to provide custom URLs for application users such as:
Quote:mysite.com/username

I have not completed the user module yet but I anticipate the route will be:
Quote:mysite.com/users/username

If parts of my application are searching the URI looking for /users/username how can I re-route the url to /username without negatively impacting the existing URI lookup?

Thank you
#2

[eluser]RJ[/eluser]
WOW, these forums have slowed down. Can anyone assist with my question?
#3

[eluser]Nick_MyShuitings[/eluser]
They have been slow lately...

I'm not sure your question is 100% clear, but if you just need to reroute anything that is currently directing to user/username then you'd do it in routes.

I have a setup that does something similar, user/username is the actual path, and if the person wants to enter it that way they can... but I modified the system so that prior to throwing a 404, it checks if the path entered example.com/username is a valid username.

Theres got to be a better solution, but at the time I was just playing around with the concept, it never went to production and subsequently got ignored.

Another way that should work would be the following:

1) In the example.com/controller/method/username you could do a redirect to example.com/username
2) then in routes at the very end you could add $route['(:any)'] = "controller/method/$1";

But that would essentially eat your 404 detection and send any non existent page to the users controller which would show a "user not found" bit.

Third option: Mod your routes file to also lookup routes in the DB. This is what I have working, and in that case you could actually make more specific routes that won't catch all your 404's. ie: $route['nick'] = "users/username/nick";
#4

[eluser]RJ[/eluser]
hmmm... dynamic routes based on the profile a visitor is trying to access. I bet you could pre-load a library in the config that set the route... if the user doesn't exist it will 404.

nice..




Theme © iAndrew 2016 - Forum software by © MyBB