Forum Moderators: phranque

Message Too Old, No Replies

Fun with rewrites

         

mbhmirc1

4:07 pm on Jul 24, 2006 (gmt 0)

10+ Year Member



Sorry for my first post to be one for help, heres my problem...

I have www.domain.com/username using a 404 redirect in php that generates the id for the username that is used to pull in the correct page. www.domain.com/user.php?clientid=1234 (the 404 php file does name to id translation).

what i want to do is username.domain.com redirect to /username but I'm not sure if the 404 engine would work after a redirect. (it hasn't from my attemts so far but a trailing / would break the 404).

On top of that our usernames can be complex, such as "my name is blah" or "my.name.is.blah" but the domain.com at the end will always be the same.

I also need both system to remain working for now to maintain google rankings. I've tired the standard subdomain ones replacing the end with domain.com/%1 etc to pass to the 404 engine, howerver that doesn't seem to pass the params.

Anyone who can understand my drible capable of helping please? :)

mbhmirc1

4:09 pm on Jul 24, 2006 (gmt 0)

10+ Year Member



Sorry about the thread title, i tried to amend it, but i can't seem to find how.

jdMorgan

4:20 pm on Jul 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using a 404 response for anything except a "Page not found" is a really, really, really bad idea if you care about ranking in search engines...

A better plan would be to use RewriteMap to call your username-to-userID translation script, and rewrite --not redirect-- the request to the userID URL-path. The ability to define RewriteMaps is available only at the server config level and not in .htaccess, but once the map is defined, it can be used from the .htaccess level.

Another way to do this would be to simply rewrite all username requests to your main script, have the script look up the ID, and use it -- without any redirects or error responses at all.

Jim

mbhmirc1

6:32 pm on Jul 24, 2006 (gmt 0)

10+ Year Member



Yeah we changed the reponse headers on the 404 so it doesn't actually return a 404. I'll have a look at the mapping side, but any ideas in the mean time as anything else i would imagine would be a major change.

mbhmirc1

6:34 pm on Jul 24, 2006 (gmt 0)

10+ Year Member



rewritemap is no good, it would end up several gig from what I can tell. We have 150,000 users at present growing 500 a day.

jdMorgan

7:25 pm on Jul 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the RewriteMap option for calling an external script. As I said, you'd use your original username-to-userID script...

Jim