Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

re-write rule for a REST API (php)

$
0
0

Hi, 

I need some help on how to write the web config so that a url will go via a php script.

On apache i had some lines of code in a .htaccess file which looked like this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* api.php/$0 [L]

Which works a treat if i go to :

localhost/api/scripts/

or 

localhost/api/scripts/{name}

it works fine, but the deployment server it turns out isnt apache, its IIS so i need to work out how to get the web config to do the same sort of thing that the .htaccess did.

So i tried (with vane) to get it to work this is what i have come up with so far:

<?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules><rule name="redirect to api" stopProcessing="true"><match url="/scripts/" /><action type="Rewrite" url="api.php" /></rule></rules></rewrite></system.webServer></configuration>

The idea is i have this file sat in the folder webroot/api/ also in there i have my api.php along with other php files for it to work. so the aim is that the user can put in:

webroot/api/scripts/

or

webroot/api/scripts/scriptname

and the api.php captures the uri and then handles it.

but it doesnt work,

if anyone has any ideas that would be fantastic

vade



Viewing all articles
Browse latest Browse all 27852

Trending Articles