Forum Moderators: phranque

Message Too Old, No Replies

Newbie To Mod Rewrite

         

oceanwave

11:51 pm on Jan 20, 2007 (gmt 0)

10+ Year Member



Hello Everyone,

A program I am using generates individual member pages that look like http:// mysite.com/index.php?action=view_user&user=2

Each member has a different user number at the end of the url.

Is it possible for the url to look like http:// mysite.com/2 (the last number would be different for each user).

Mod_rewrite is enabled on the server.

There is an htaccess file with rewrites for other pages. Those work but I would like to add this new rule.

I have searched but haven't been able to find an example that has the action statement and changing numbers in the url. This is my first attempt with mod_rewrites, so I appreciate simple explanations. Thank you for any help!

oceanwave

3:07 pm on Jan 21, 2007 (gmt 0)

10+ Year Member



Did some more reading. Found an example that is similar to what I want. Tried it, but there was no change in the url.

Why doesn't this work? Is it because of the action part of the url?

RewriteRule ^member/([A-Za-z0-9-]+)/([0-9]+)/?$ index.php?action=$1&user=$2 [L]

jdMorgan

6:03 pm on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule ^member/([A-Za-z0-9-]+)/([0-9]+)/?$ index.php?action=$1&user=$2 [L]

This code will rewrite requests for /member/view-widget/33/ to /index.php?action=view-widget&user=33

Is that what you want?

Jim

oceanwave

8:40 pm on Jan 21, 2007 (gmt 0)

10+ Year Member



Hi Jim,

Thank you so much for responding.

The program I am using creates a profile page for each user. Unfortunately, the long and complicated urls are too difficult for each user to remember.

http:// mysite.com/index.php?action=view_user&user=2
(the number is different for each user)

I am trying to simplify the urls so that a user can tell others where their page is located.

Look forward to hearing from you.

jdMorgan

3:34 pm on Jan 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This code will rewrite requests for /member/view-widget/33/ to /index.php?action=view-widget&user=33

Is that what you want?

Yes? No?

Jim

oceanwave

12:07 am on Jan 28, 2007 (gmt 0)

10+ Year Member



Hi Jim,

Thanks for responding. Still have not found the answer.

I would actually prefer /member/33/ if possible. At this point, I am trying for anything!

The rewrite code I referred to above does not work when I paste it into the htaccess file. I just want urls like the one below to be user friendly (the number is different for each member). Any suggestions?

[mysitename.com...]