tags:

views:

96

answers:

4

Hello,

I have a php script on a webserver. Currently, the script is being accessed as http://www.mydomain.com/scriptname.php . Is there a way i can create a user friendly url for accessing this script, something like http://www.mydomain.com/appname, so when this url is called it invokes the php script ?

Please help. Thank You

+7  A: 

You want mod_rewrite if you're using Apache HTTPD: http://httpd.apache.org/docs/1.3/mod/mod%5Frewrite.html

If you're using a different web server, it may have something similar (lighttpd has a similar functionality builtin).

Once it's enabled, you can use something like this in your .htaccess file to rewrite appname to scriptname.php

RewriteEngine on
RewriteRule ^appname$ scriptname.php
Jeffrey Aylesworth
+3  A: 

If you don't have access to your apache/lighttpd configuration file a little hack that may work is putting the script in http://www.mydomain.com/appname/index.php; http://www.mydomain.com/appname/ will then probably work.

Andreas Bonini
Thanks for the reply Andreas. Actually this was what i was looking for as i have purchased an account with a web hosting provider, but dont have shell access. Thank You !
Tomj
You don't need shell access to change .htaccess settings. But if this works for you, it is fine as well.
Pekka
You could also rename your script to `appname.php`, and as long as there is no `appname` directory there as well, Apache will usually execute the .php file.
pix0r
A: 

Using the default settings of most PHP hosts, you can put the file "index.php" inside your folder http://www.mydomain.com/appname, then fill the index.php with next code:

<?php
header("location: http://www.mydomain.com/scriptname.php");
?>

That would do it.

alemjerus
That would do a redirect. Among other things, that would change the URL to http://www.mydomain.com/scriptname.php, which I assume the asker does not want.
mjs
+2  A: 

Your title is "creating a RESTful .." - There's nothing really RESTful about your question, so I'm assuming you don't really know what REST is and how it is used - if your an API programmer, or programmer of clients that consume a RESTful API, you should definitely read up on REST.

Starting points are:

http://en.wikipedia.org/wiki/Representational%5FState%5FTransfer

http://tomayko.com/writings/rest-to-my-wife

Mr-sk