Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 2nd, 2001, 09:39 AM
puttie puttie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 8 puttie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

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

Reply With Quote
  #2  
Old May 2nd, 2001, 05:13 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > .htaccess and redirecting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway