apache encode special characters in URL


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users apache encode special characters in URL
# 1  
Old 07-23-2008
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  
Old 07-23-2008
Tools 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  
Old 07-24-2008
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  
Old 07-25-2008
Or do you mean something like mod_rewrite's escape function? See e.g. Mod_Rewrite Forums :: Index
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using CURL command with special characters in URL

Hi. I 'm trying to hit a REST api and retrieve a JSON feed, and the URL has special characters in it. Something like: Example Domain The below curl command is failing curl -X GET https://www.example.com/?sample=name&id=1001 saying bad command at id=1001 I am going to use this as part... (3 Replies)
Discussion started by: kumarjt
3 Replies

2. Web Development

apache url redirection

I need help in apache url redirection: I have added the below command in httpd.conf and it is working fine. Redirect http://xyz.com/site/homehttp://abc.com/site/home Can we set a rule such that http://xyz.com/site/* -> http://abc.com/site/* is applied For... (0 Replies)
Discussion started by: raghur77
0 Replies

3. UNIX for Advanced & Expert Users

apache webserver url redirection

I need help in apache url redirection: I have added the below command in httpd.conf and it is working fine. Redirect http://xyz.com/site/homehttp://abc.com/site/home Can we set a rule such that http://xyz.com/site/* -> http://abc.com/site/* is applied For... (0 Replies)
Discussion started by: raghur77
0 Replies

4. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

5. Web Development

Apache Virtual URL

Hi All, i'am facing a problem with urls that don't have a filestructure under DocumentRoot. A URL like http://mydomain.com/applicationrew/Structure1/Structure2/some?parameter=key&parameter1=key1 Should be rewritet to something else. Now i defined a Location like <Location ~... (3 Replies)
Discussion started by: wuschelz
3 Replies

6. Web Development

Negate user space URL in Apache

Hello, I have a situation where I am trying to use Apache's RedirectMatch directive to redirect all users to a HTTPS URL except a single (Linux) user accessing there own webspace. I have found a piece of regular expression code that negates the username: ^((?!andy).)*$but when I try using it... (0 Replies)
Discussion started by: LostInTheWoods
0 Replies

7. Shell Programming and Scripting

redirecting a url on apache conf file

i need help on redirecting apache conf file i want redirect everything to www.example.com/home example if i type a url www.example.com/home/text1 i need that redirected to www.example.com/home (0 Replies)
Discussion started by: shehzad_m
0 Replies

8. Web Development

APACHE rewrite / redirect URL

Hello. I have scenario where a Client send request to Server1. Server1 send request to Server2. Request are xmlHTTPRequest - need to get data (XML) from Server2 back to client. Trying to use APACHE proxy... Anyone can help? What to download / configure / ...? Thank you for your... (2 Replies)
Discussion started by: ampo
2 Replies

9. Cybersecurity

APACHE rewrite / redirect URL

Hello. I have scenario where a Client send request to Server1. Server1 send request to Server2. Request are xmlHTTPRequest - need to get data (XML) from Server2 back to client. Trying to use APACHE proxy... Anyone can help? What to download / configure / ...? Thank you for your help. (1 Reply)
Discussion started by: ampo
1 Replies

10. UNIX for Dummies Questions & Answers

Apache, hiding the url

Hello, how to hide the full addres url, in apache web server. eg, www.example.org/www/pub/index.html, the address in browser only www.example.org . Thank You. (2 Replies)
Discussion started by: blesets
2 Replies
Login or Register to Ask a Question