Hi all!
I made a user_template.php for displaying any user's information from a database, however, I have a few questions after reading the modrewrite FAQ and the Working with Forms Tutorial.
I want users to come to http://www.domain.com/username to be redirected to http://www.domain.com/user_template.php?user=username.
1) Since my modrewrite won't contain numbers (as it did on the short tutorial at http://codewalkers.com/faq/4/13.html) and just ID's, how would I do it? Would it be something like this in my .htaccess file?:
[quote]
RewriteEngine on
RewriteBase /
RewriteRule ^(<what goes here>+)/$ /user_template.php?user=$1
[/quote]
2) I do have access to my .htaccess file, but it already has a bit of stuff in it. One thing: my current .htaccess is in the /logs directory of my server. Can I make a new .htaccess for the root directory of my server (dont I have to do that?)?
Thanks a lot guys!
-BUMPle.
Mod Rewrite quick help!
Moderator: General Moderators
-
steve@oeic.net
- Forum Newbie
- Posts: 8
- Joined: Wed Feb 18, 2004 2:47 pm
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
I got it to work like this:
RewriteRule ^user_(.*)$ user_template.php?user=$1
it however requires you to prepend user_ to the actual username like so:
http://www.domain.com/user_username
or use this:
RewriteRule ^user/(.*)$ user_template.php?user=$1
and call it like
http://www.domain.com/user/username
Else I don't know, since you'd have to make sure you can still call normal pages (index.php) and subdirectories. Your regex would have to catch these.
RewriteRule ^user_(.*)$ user_template.php?user=$1
it however requires you to prepend user_ to the actual username like so:
http://www.domain.com/user_username
or use this:
RewriteRule ^user/(.*)$ user_template.php?user=$1
and call it like
http://www.domain.com/user/username
Else I don't know, since you'd have to make sure you can still call normal pages (index.php) and subdirectories. Your regex would have to catch these.
I'm getting there...but take for example xanga's website.
If you type in:
http://www.xanga.com/ilovecats
it will automatically redirect you to:
http://www.xanga.com/home.aspx?user=ilovecats
How did they do that?
Thanks!
-BUMPle.
If you type in:
http://www.xanga.com/ilovecats
it will automatically redirect you to:
http://www.xanga.com/home.aspx?user=ilovecats
How did they do that?
Thanks!
-BUMPle.
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria