0

I'm trying to get the back end of an app that was built by someone else, and then taked down, up and running again. I have uploaded the unmodified back end sourcecode to a dev server (not the original server it was on).

In the app, the URL to access a certain API is as such: [hostname]/controllers/api/user/profile

and when looking at the back end php code, under the api folder there is a user.php file, and in that php file there is a function called "profile", and there is one for every api end point.

now the only way I know of to do this is to have an .htaccess file that redirects a request to /controllers/user/profile to /controllers/user.php?action=profile, and have a big switch statement in user.php that calls the function corresponding to "action" parameter.

But the weird thing is that there is no .htaccess file in the the api folder. The only .htaccess file is in the absolute root of the folder containing all the server code, and that just says deny from all

is there any other way to set up a server to cause requests to .../folder/functionName to actually call a function within a php file, other than using .htaccess?

Siavash
  • 7,583
  • 13
  • 49
  • 69
  • You can't modify global .htaccess? – fusion3k Feb 15 '16 at 01:28
  • I can, but I'm pretty low level with back end stuff (Im android developer), and I want to make sure that they hadn't implented this using some other method which is more advanced and correct... basically I don't want to jerry rig it. – Siavash Feb 15 '16 at 01:30
  • I think that only method is through .htaccess. You can edit your main .htaccess or add a .htaccess to interested directory. – fusion3k Feb 15 '16 at 01:36
  • Check the vhost, which is the correct place for such rules (unless you're on shared hosting and have no access) – rjdown Feb 15 '16 at 01:44
  • @rjdown can you please elaborate? – Siavash Feb 16 '16 at 18:04
  • They are server configuration files for your site. They tell it where your site lives, which aliases your domain has and various other settings. Anything that's in an htaccess file _should_ be going into there instead. On nix they are usually in `/etc/apache2/sites-available/yourdomain.conf`, on windows something like `C:\WAMP\apache\conf\extra\httpd-vhosts.conf` – rjdown Feb 16 '16 at 18:58

1 Answers1

0

It can be done through a PHP redirect. It is described here in details: How to make a redirect in PHP?

Community
  • 1
  • 1
EmilCataranciuc
  • 1,024
  • 1
  • 11
  • 24
  • but the original url in the app is a path to a particular function, so it would not resolve to a php file to run. there must be something that happens out side of the php script to send the request to a particular file. – Siavash Feb 16 '16 at 18:03
  • You should provide more info, for example what framework was used for the project. Maybe there is a routing file which must be edited. – EmilCataranciuc Feb 16 '16 at 18:38