Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-17-2004, 07:14 AM
WebProWorld New Member
 

Join Date: Oct 2004
Posts: 3
sampleman7 RepRank 0
Default htaccess redirect scenerio question.

Hello :)
Ive seen a lot of websites use this technique, and I'm assuming they use htaccess to accomplish it, I'm just clueless of proper syntax. Here's the scenerio...

User types...
"http://yourdomain.com/anyword"
htaccess would redirect to...
"http://yourdomain.com/cgi-bin/script.cgi?parameter=anyword"

Is this a redirect or a rewrite, and what's the syntax?

Help is greatly appreciated!
(Newby at this forum!)
Dennis
Reply With Quote
  #2 (permalink)  
Old 10-17-2004, 11:45 AM
httpman's Avatar
WebProWorld Pro
 

Join Date: Aug 2003
Location: France
Posts: 196
httpman RepRank 0
Default Re: htaccess redirect scenerio question.

Hello sampleman7

You could find answers there :
http://www.webdeveloper.com/servers/...ess_magic.html

or better yet, there :
http://wsabstract.com/howto/htaccess.shtml

JP
__________________
www.net-createurs.com [ french only website sorry ! ]
Reply With Quote
  #3 (permalink)  
Old 10-17-2004, 12:15 PM
paulhiles's Avatar
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: UK
Posts: 2,803
paulhiles RepRank 0
Default Using .htaccess to redirect

Hi Dennis,

Looks like a redirect to me. A redirect instruction in a .htaccess file has three elements. The redirect command itself, the file or directory you want to redirect, and finally the full URL of the destination file or folder. Note: each element is separated by a single space.

So, using the scenario you describe above, I would say the .htaccess file should contain the following:

Hope that helps!

Paul
Reply With Quote
  #4 (permalink)  
Old 10-17-2004, 04:00 PM
WebProWorld New Member
 

Join Date: Oct 2004
Posts: 3
sampleman7 RepRank 0
Default

ok, really "my bad" here, that I didn't explain this properly....

"anyword" is input by the user, and is not solidly defined. It literally would be "any word". I want the user's input to be added to the redirect. What I'm accomplishing is letting viewers of my site to view a member's profile by just entering a screenname after the domain...

"http://mydonain.com/anyusername"

anyusername can be anyone's user name, and is added to the actual script command...

"http://mydomain.com/cgi-bin/index.cgi?username=anyusername"

So, in other words, I want to capture whatever the user types in place of "anyusername" copy it, and place it at the end of the redirect.

I have even contacted a couple websites to see how they are accomplishing this, but nobody has responded. It's like a trade secret.

Thanks guys for your time, I really do appreciate it!
Dennis :)
Reply With Quote
  #5 (permalink)  
Old 10-17-2004, 05:23 PM
WebProWorld New Member
 

Join Date: Oct 2004
Posts: 3
sampleman7 RepRank 0
Default SOLUTION FOUND!

RewriteRule ^_([^/]+)/?$ cgi-bin/index.cgi?action=viewprofile&username=$1 [R]

With this, I have to tell my users to place an underscore before the name, so that it separates just a single word, and a file with an extention, or any other reference that could conflict!

Take away the underscore in the rule, and any word would apply to the redirect. Great for people that don't have any other files to point to other than their script!

Yay!
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0