org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused in android

I am making an application that uploads images to server and updates its database to server in android while executing it, it shows an error

Connection to http://localhost refused 

and many more errors, I researched this problem and found instead of providing the URL connection

http://localhost/... provide the link as http://10.0.2.2/... 

and I did so but the problem is same more error is here:

E/org.apache.http.conn.HttpHostConnectException(4318): Connection to http://localhost refused
E/org.apache.http.conn.HttpHostConnectException(4318): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
E/org.apache.http.conn.HttpHostConnectException(4318):  at com.example.android.photobyintent.ViewRecipients.uploadFile(ViewRecipients.java:325)
E/org.apache.http.conn.HttpHostConnectException(4318):  at com.example.android.photobyintent.ViewRecipients$1.run(ViewRecipients.java:238)
E/org.apache.http.conn.HttpHostConnectException(4318):  at java.lang.Thread.run(Thread.java:856)
E/org.apache.http.conn.HttpHostConnectException(4318): Caused by: java.net.ConnectException: failed to connect to /127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
E/org.apache.http.conn.HttpHostConnectException(4318):  at libcore.io.IoBridge.connect(IoBridge.java:114)
E/org.apache.http.conn.HttpHostConnectException(4318):  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
E/org.apache.http.conn.HttpHostConnectException(4318):  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
E/org.apache.http.conn.HttpHostConnectException(4318):  at java.net.Socket.connect(Socket.java:842)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
E/org.apache.http.conn.HttpHostConnectException(4318):  at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
E/org.apache.http.conn.HttpHostConnectException(4318):  ... 8 more
E/org.apache.http.conn.HttpHostConnectException(4318): Caused by: libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
E/org.apache.http.conn.HttpHostConnectException(4318):  at libcore.io.Posix.connect(Native Method)
E/org.apache.http.conn.HttpHostConnectException(4318):  at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
E/org.apache.http.conn.HttpHostConnectException(4318):  at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
E/org.apache.http.conn.HttpHostConnectException(4318):  at libcore.io.IoBridge.connect(IoBridge.java:112)
E/org.apache.http.conn.HttpHostConnectException(4318):  ... 13 more

the code for file upload is:

public int uploadFile(ArrayList<String> sourceFileUri, String info, String latitude, String longitude, String id) throws IOException {
        try {
            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpPost httpPost = new HttpPost("http://10.0.2.2/deliverysystem/order/add");

            MultipartEntity entity = new MultipartEntity(
                    HttpMultipartMode.BROWSER_COMPATIBLE);

            entity.addPart("returnformat", new StringBody("json"));
            System.out.println(sourceFileUri.size());
            for(int i=0;i<sourceFileUri.size();i++){
                String sourceFile = sourceFileUri.get(i);
                entity.addPart("uploaded_file"+(i+1), new FileBody(new File(sourceFile)));
            }

            entity.addPart("fld_delivery_id", new StringBody(id));
            entity.addPart("fld_delivery_location", new StringBody(info));
            entity.addPart("fld_latitude", new StringBody(latitude));
            entity.addPart("fld_longitude", new StringBody(longitude));
            httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost, localContext);
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(
                            response.getEntity().getContent(), "UTF-8"));

            String sResponse = reader.readLine();
            return 1;
        } catch (Exception e) {
            if (dialog.isShowing())
                dialog.dismiss();

            Log.e(e.getClass().getName(), e.getMessage(), e);
            return 1;
        }

       }

while debugging the code reaches up to:

httpPost.setEntity(entity);

and it shows exception after this line ie on this statement:

HttpResponse response = httpClient.execute(httpPost, localContext);

Could any one help me on this?

Premature end of script headers: media ( Issue related to :rails app deployment+passenger+ubuntu+apache)

i just setup a linode server and deploy my rails 3 app on it.its up and running.The problem is that some images are not showing up in the production.locally they are perfectly working.i double checked the log file(production.log) but nothing found.then i check server error.log file that says.

[Sat Dec 29 22:54:14 2012] [error] [client 182.177.228.157] Premature end of script headers: media, referer: http://50.116.57.152/app?v=11&o=33

Check out http://50.116.57.152/app?v=11&o=33  for live demo.

Thanking in advance.

.htaccess Redirect to specific webpage based on browser

I want to redirect visitors to my specific page based on which browser they are using.

For example: all visitors will first visit http://www.example.com/xy/abc.html.

If the visitor is using firefox, he should be redirected to http://www.example.com/xy/firefox.html

If the visitor is using chrome, he should be redirected to http://www.example.com/xy/chrome.html

I want to handle this for opera, chrome, firefox, IE, safari browser and with a default redirect for non identified browser.

Any help with the code? I tried looking up and all I found was a single redirect code for all browser rather than a specific one.

Your help is appreciated. Thanks.

MAMP virtual hosts not working when connected to home network

I have virtual hosts setup on my laptop, which I know work fine as I use them often for work and school, but for whatever reason when I'm at my parents house connected to their home network I get 404'd. If I disconnect form the network I get servered the page fine by Apache. Here is my httpd.conf file contents (only the portion dealing with virtual hosts):

NameVirtualHost *
<VirtualHost *>
    DocumentRoot "/Applications/MAMP/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *>
    DocumentRoot "/Users/kyle/Sites/ESA/app/public"
    ServerName esa.loc
    <Directory "/Users/kyle/Sites/ESA/app/public">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

<VirtualHost *>
    DocumentRoot "/Users/kyle/Sites/portfolio-site/public"
    ServerName kyle.loc
    <Directory "/Users/kyle/Sites/portfolio-site/public">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

and my /etc/hosts file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost esa.loc kyle.loc
255.255.255.255 broadcasthost
::1             localhost esa.loc kyle.loc
fe80::1%lo0     localhost esa.loc kyle.loc

If you need anymore information let me know and I'll do my best to provide it. Thanks.

EDIT: Forgot to mention that I tried adding my laptop to the DMZ on the router but that didn't fix the issue.

htaccess redirect to https://www

I have the following htaccess code:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

</IfModule>

I want my site to be redirected to https://www. but when I access http://www. does not redirect me to https://www.

Apache Alias Directory

How can I use an Alias Directory as a subdomain, for example when I use my subdomain http://subdomain.domain.com and I click a link I go to http://subdomain.domain.com/new-link but when I use an Alias http://domain.com/Alias and I click a link I go to http://domain.com/new-link and I want to go to http://domain.com/Alias/new-link it means I want to mantain http://domain.com/Alias/

¿Any Ideas?

Apache Alias Directory

How can I use an Alias Directory as a subdomain, for example when I use my subdomain http://subdomain.domain.com and I click a link I go to http://subdomain.domain.com/new-link but when I use an Alias http://domain.com/Alias and I click a link I go to http://domain.com/new-link and I want to go to http://domain.com/Alias/new-link it means I want to mantain http://domain.com/Alias/

¿Any Ideas?

Apache Alias Directory

How can I use an Alias Directory as a subdomain, for example when I use my subdomain http://subdomain.domain.com and I click a link I go to http://subdomain.domain.com/new-link but when I use an Alias http://domain.com/Alias and I click a link I go to http://domain.com/new-link and I want to go to http://domain.com/Alias/new-link it means I want to mantain http://domain.com/Alias/

¿Any Ideas?

Apache Alias Directory

How can I use an Alias Directory as a subdomain, for example when I use my subdomain http://subdomain.domain.com and I click a link I go to http://subdomain.domain.com/new-link but when I use an Alias http://domain.com/Alias and I click a link I go to http://domain.com/new-link and I want to go to http://domain.com/Alias/new-link it means I want to mantain http://domain.com/Alias/

¿Any Ideas?