Link to home
Start Free TrialLog in
Avatar of dward81
dward81

asked on

How Would I Rewrite This URL Using Mod Rewrite?

Avatar of Arasian
Arasian
Flag of United States of America image

You need to look at .htaccess files.  An .htaccess file modifies the directory it exists in and any directories under it.  So you would put yours in your root level web directory (http://www.trytlc.com)

Within this .htaccess file, you'd write the following (I don't have a way to test this at the moment but I'm pretty sure this will work)
RewriteEngine On
RewriteRule dward\/(.*)$ http://www.trytlc.com/$1?user=dward [L]

Open in new window

Avatar of dward81
dward81

ASKER

Thank you veyr much for the help. The only problem I have now is that the dward part of the url is dynamic and can change with every user. So how would I modify this to reflect that.

RewriteEngine On
RewriteRule dward\/(.*)$ http://www.trytlc.com/$1?user=dward [L]
What you'll have to do is say (pseudocode)
http://www.trytlc.com/USER/FILE = www.trytlc.com/FILE?user=USER.  The problem with that, though is that kills all your real subdirectories in your domain.  So you'll have to have some kind of user delimiter (frequently a tilde), which will make it www.trytlc.com/~dward/FILE.

Your other option is www.trytlc.com/users/dward/FILE.

Which one would you like the script for?
Avatar of dward81

ASKER

I think the delimeter with the tilde would be the best bet for my application.

www.trytlc.com/~dward/FILE
ASKER CERTIFIED SOLUTION
Avatar of Arasian
Arasian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ahhh, add an [L] on the end as in the first example.
Avatar of dward81

ASKER

Thank You very much for the help. I appreciate it greatly.