|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I dont know if this is already posted on this forum before, but i saw it on another forum somewhere, but i didn't understand it verry wel. So if somebody could explain that would help alot.
Here is the situation: if somebody goes to www.mydomain.com/name (for example www.mydomain.com/puttie) then the script has to redirect the user to www.mydomain.com/userpage.php?username=name (for example www.mydomain.com/userpage.php?username=puttie) I think this has to be done with .htaccess, but i dont know how. Thanks in advance |
|
#2
|
|||
|
|||
|
First off, you have got a real bad idea for redirecting www.mydomain.com/puttie to whatever simply because /puttie is the very top level relative URL. Everyone is unable to access your main site because a redirection will occur immediately. Instead, you should use a 2nd level relative URL like so:
www.mydomain.com/user/puttie to www.mydomain.com/userpage.php?username=puttie or puttie.mydomain.com to www.mydomain.com/userpage.php?username=puttie (if wildcard is enabled in your DNS configuration) Second, what about accessing to www.mydomain.com/user/puttie/dir/blahblah.html ? I don't think you really have any idea what you are trying to do. Let's forget about your bad idea and use my 1st example: #http://www.mydomain.com/.htaccess #username must contain only a to z 0 to 9 chars #when accessing to www.mydomain.com/user/username or www.mydomain.com/user/username/ RewriteEngine on RewriteRule ^/user/([a-z0-9]+)([^/]*)$ userpage.php?username=$1 [R,L] My 2nd example: # Redirect http://puttie.mydomain.com or http://puttie.mydomain.com/ to http://www.mydomain.com/userpage.php?username=puttie RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC] RewriteRule ^(.+) - [L] RewriteCond %{HTTP_HOST} ^[^.]+\mydomain\.com$ [NC] RewriteRule ^(.+) %{HTTP_HOST}=$1 [C] RewriteRule ^([^.]+)\.mydomain\.com(.*) http://www.mydomain.com/userpage.php?username=$1 [R,L] >> I dont know if this is already posted on this forum before Yes, dozen times already and you should do a search first. Last edited by freebsd : May 2nd, 2001 at 05:16 PM. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > .htaccess and redirecting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|