Welcome Guest, Not a member yet? Register   Sign In
Routing issues
#1

[eluser]kilishan[/eluser]
First, yes, I have done a search and tried everything that's recommended. Nothing seems to be working for this...

I am working on a social networking site and want to have the url's take you to the user, like so: www.critormiss.com/username. What I have works fine right now, by going to critormiss.com/user/username. It looks up the name and performs as it should.

In my routes, The very last command is:
Code:
$route[':any'] = "user";
From what I've read, this should do it. However, when I try it out, I get the following error from Firefox (2.0.0.7):

Quote:The page isn't redirecting properly.

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

It does, however, redirect me back (after a long wait) to the default controller, which is still welcome.php for now. All of the other routing seems to be working.

I have also tried it in IE 7, but no luck. And I've tried:
Code:
$route['(.*)'] = "user/$1";

and a couple other variations.

I am on Windows Vista, using Xampp for mysql/php/apache. My htaccess file is:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|tmp|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Any ideas what would be causing this?

Thanks!
#2

[eluser]Michael Wales[/eluser]
What you are doing is the correct way... I'd remove the .htaccess file for now - see if that is what is causing the issues. I don't think it's the routing.
#3

[eluser]kilishan[/eluser]
You're right. It wasn't an issue with the routing. Nor was it an issue with the htaccess file.

Thanks for the fast reply!

And for others that have this issue, since I've seen similar problems crop up, here's the problem that I was having:

The problem was how I was checking for the user name. When the controller was not being remapped, checking $this->uri->segment(2) gave me the name. Great. However, once it was routed, it turns out that I now have to use segment(1) instead.

I tried using rsegment(2) but it still didn't give me an empty string. I also tried using rsegment(1) which gave me 'user', which is what I expected. So I'm not sure how the rsegment function actually works, but just checking segment(2) gets it done. It doesn't however, allow url's like 'www.critormiss.com/user/username'. I don't think that's a problem, but I'm still curious why the rsegment didn't work...

Thanks again!




Theme © iAndrew 2016 - Forum software by © MyBB