The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Array with special Characters donaldfung UNIX for Dummies Questions & Answers 1 06-08-2008 12:18 PM
Grep with Special Characters Vashj Shell Programming and Scripting 6 11-27-2007 06:51 AM
Put a \ in front of special characters in SED tugger Shell Programming and Scripting 9 10-17-2007 07:12 AM
special characters nawnaw UNIX for Dummies Questions & Answers 2 05-18-2004 03:17 PM
awk/sed with special characters apalex Shell Programming and Scripting 5 05-06-2002 04:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-23-2008
uttamhoode uttamhoode is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 18
apache encode special characters in URL

Hi all,

How can I enable encoding of special characters present in URL?

eg

If the URL is

http://127.0.0.1/test.cgi?param1=test & test co

it shouldbe encoded to

http://127.0.0.1/test.cgi?param1=test%20%26%20test%20co

Thanks and Reagards,
uttam hoode
  #2 (permalink)  
Old 07-23-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Cool Does this help?

Code:
> inval="http://127.0.0.1/test.cgi?param1=test & test co"
> echo "$inval"
http://127.0.0.1/test.cgi?param1=test & test co
> outval=$(echo "$inval" | sed "s/ /%20/g" | sed "s/&/%26/g")
> echo "$outval"
http://127.0.0.1/test.cgi?param1=test%20%26%20test%20co
  #3 (permalink)  
Old 07-24-2008
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Well, there are far more special characters that need escaping instead of just a space or ampersand. In what way would you like to do the URL escape? Can you explain further your situation?

By the way, if the URLs are generated by dynamic scripting such as PHP or Perl, parameter escaping is usually handlded by default or there is API for you to do the needed encoding, so you typically do not need to worry about escaping at all.

For Perl, if you don't mind installing CPAN modules, the easiest and most reliable way is to use the URI module (this is my favourite). It can parse, and create many kinds of properly formatted URLs. This is an example:

URI::QueryParam - Additional query methods for URIs - search.cpan.org
  #4 (permalink)  
Old 07-25-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Or do you mean something like mod_rewrite's escape function? See e.g. Mod_Rewrite Forums :: Index
Sponsored Links
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0