![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array with special Characters | donaldfung | UNIX for Dummies Questions & Answers | 1 | 06-08-2008 09:18 AM |
| Grep with Special Characters | Vashj | Shell Programming and Scripting | 6 | 11-27-2007 03:51 AM |
| Put a \ in front of special characters in SED | tugger | Shell Programming and Scripting | 9 | 10-17-2007 04:12 AM |
| special characters | nawnaw | UNIX for Dummies Questions & Answers | 2 | 05-18-2004 12:17 PM |
| awk/sed with special characters | apalex | Shell Programming and Scripting | 5 | 05-06-2002 01:40 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
Or do you mean something like mod_rewrite's escape function? See e.g. Mod_Rewrite Forums :: Index
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|