You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Fredric Fredricson <Fr...@bonetmail.com> on 2010/07/22 19:31:06 UTC

[users@httpd] Config for a PHP REST web service

Hi all,
I am working on a small REST-based web service that I write in php.
I have a single PHP-script and I want Apache to route all requests to a 
specific location and below to my php script.

This is how I did it:

<LocationMatch "^/pathtomyservice(.*)" >
<Limit GET POST PUT DELETE OPTIONS>
         Order allow,deny
         Allow from all
</Limit>
<LimitExcept GET POST PUT DELETE OPTIONS>
         Order deny,allow
         Deny from all
</LimitExcept>

     Options -All
     SetHandler MyService
     Action MyService /~myuser/somepath/myscript.php virtual
</LocationMatch>

of course, I had to enable UserDir for myuser.

My problem is: I have no idea what I am doing. It's all 
trial-and-horror. Now it works as expected but somehow it feels a bit 
strange.

I expected to be able to tell Apache that "for this path run that php 
script" and not that the script had to be accessible via http and all 
that "handler" business.

So if somebody more in the know could bless this solution or tell me how 
to really do it would be grateful. Or even point me to the correct 
configuration directives.

/Fredric

PS. I run on a range from 1.3 to 2.2 but the solution will only have to 
work for 2.2 (and newer).


Re: [users@httpd] Config for a PHP REST web service

Posted by Fredric Fredricson <Fr...@bonetmail.com>.
  On 07/22/2010 10:50 PM, Simone Caruso wrote:
> On 22/07/2010 19:31, Fredric Fredricson wrote:
> > Hi all,
> > I am working on a small REST-based web service that I write in php.
> > I have a single PHP-script and I want Apache to route all requests 
> to a specific location and below to my php script.
> >
> did u try mod_rewrite?
> RewriteRule ^(.*)$ /YOURSCRIPTPATH/index.php/$1 [L]
Thank you, that was what I needed. After I outsmarted SELinux it worked 
fine.
/Fredric
>
> > I expected to be able to tell Apache that "for this path run that 
> php script" and not that the script had to be
> > accessible via http and all that "handler" business.
>
> You can use locationMatch or .htaccess files:
> RewriteCond %{REQUEST_URI} !^(/js|/imgages)
> RewriteRule ^(.*)$ /YOURSCRIPT.php/$1 [L]
>


Re: [users@httpd] Config for a PHP REST web service

Posted by Simone Caruso <in...@simonecaruso.com>.
On 22/07/2010 19:31, Fredric Fredricson wrote:
 > Hi all,
 > I am working on a small REST-based web service that I write in php.
 > I have a single PHP-script and I want Apache to route all requests to a specific location and below to my php script.
 >
did u try mod_rewrite?
RewriteRule ^(.*)$ /YOURSCRIPTPATH/index.php/$1 [L]

 > I expected to be able to tell Apache that "for this path run that php script" and not that the script had to be
 > accessible via http and all that "handler" business.

You can use locationMatch or .htaccess files:
RewriteCond %{REQUEST_URI} !^(/js|/imgages)
RewriteRule ^(.*)$ /YOURSCRIPT.php/$1 [L]

-- 
Simone Caruso
IT Consultant
+39 349 65 90 805
p.iva: 03045250838

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org