I have a problem to display WFS layer outside the GeoServer. My code working fine in GeoServer, but when I tried my code in WampServer(PHP), only WMS layer is being to displayed.

I've gone through many tutorial and stack overflow queries related to adding WFS layer in OpenLayers but nothing working in my case... I have also tried proxy.cgi scripts to allow proxy call to GeoServer, but it not works. Is CGI proxy script can be used only with Python or it can be used with PHP as well?

  • have you tried using a PHP proxy file? Apr 1, 2013 at 7:28
  • could you please help me : I want to show postgres query output in openlayer using php.?
    – user37155
    Sep 18, 2014 at 10:15
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation.
    – Martin
    Sep 18, 2014 at 10:37
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context.
    – Brad Nesom
    Sep 18, 2014 at 12:38

1 Answer 1


You need a PHP proxy. This is a simple proxy.php script. It will be completely open, and you might want to lock it down.

 $ch = curl_init($_GET['url']);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $output = curl_exec($ch);
 echo $output;

In your OpenLayers JavaScript config point to you proxy.php script with the following:

OpenLayers.ProxyHost = "proxy.php?url=";

Source: http://osgeo-org.1560.n6.nabble.com/proxy-and-apache-tp3912603p3912617.html

  • Thanks for replay Devdatta Tengshe!! I have tried this but its not working. Do I have to make some changes in conf file or some any other file. Apr 1, 2013 at 11:21
  • What do you mean when you say it is not working? Are you getting any errors in Firebug? Apr 1, 2013 at 14:08
  • Firebug not showing any error only WMS layer is being displayed means WFS layer is still missing. Apr 1, 2013 at 22:59
  • If firebug's console is not showing any error that means the problem is somewhere else. Is the request atleast being sent? (See in the net tab of firebug) Apr 2, 2013 at 1:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.