0

I basically have a file like this:

user.php

It has different get Parameters:

user.php?method=GetUserData
user.php?method=SetUserData

I want to call it according to REST like this:

server.com/GetUserData
server.com/SetUserData

Is this possible?

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
ScarWolf
  • 3
  • 1
  • 2
    yeah it is possible using `.htaccess` .. `RewriteRule ^(.*)$ user.php?method=/$1 [NC]` ref : https://httpd.apache.org/docs/current/howto/htaccess.html – Pogrindis Apr 14 '16 at 13:39
  • Possible duplicate of [.htaccess rewrite GET variables](http://stackoverflow.com/questions/7677070/htaccess-rewrite-get-variables) – Chris Apr 14 '16 at 13:40

1 Answers1

0

A more accurate version of Pogrindis' solution would be to add the following to a .htaccess file:

RewriteRule ^([GS]etUserData)$ user.php?method=/$1 [NC]

This works if these are the only two methods you need to set — as the regex pattern matches only "GetUserData" and "SetUserData".

This prevents other base links (such as http://server.com/MyPage) from being converted as well.

Pogrindis
  • 7,755
  • 5
  • 31
  • 44
strakez
  • 35
  • 5