101Bram Posted July 26, 2017 Posted July 26, 2017 Hey, I'm using processwire as a backend service (as a REST API to be more specific). I would like to let my server point at my index.html file (It is not possible to change this to a php file for many reasons), but without the index.php processwire won't work. Can processwire be used if I for example move the index.php file to a subdirectory? Kind regards, Bram
apeisa Posted July 26, 2017 Posted July 26, 2017 Yes, you can include processwire from any path: https://processwire.com/api/include/
101Bram Posted July 26, 2017 Author Posted July 26, 2017 The problem is I don't use php except for calling the API. My guess is if I go to website.com/pw_api/some_template/, Apache first looks for the file index.php, processwire is initialized and handles the route. Without the index.php the url /api/some_template doesn't have any meaning for the server.
apeisa Posted July 26, 2017 Posted July 26, 2017 Not sure I understand what you are trying to achieve. You need PHP to use PW, you cannot use it from html only. Why don't you install processwire on www,yoursite.com/api/ subdirectory? There your /index.html could be static html/js and then /api/* would go for pw. 3
101Bram Posted July 26, 2017 Author Posted July 26, 2017 Didn't know it was that simple, I really overcomplicated it with apache configurations and so. You made my day! 1
bernhard Posted July 27, 2017 Posted July 27, 2017 you should just be careful when installing pw into a subdir because sometimes this can break paths... for example if there is any link pointing to the root ( "/" ) it would NOT point to the right direction, because it should actually point to "/api/" you could overcome this using a subdomain. if thats possible in your case i would recommend using api.yourdomain.com instead of yourdomain.com/api/
blynx Posted July 27, 2017 Posted July 27, 2017 Would that be an option: Run Processwire as your main entry point / site and echo the html file in the home template to render it? <?php echo file_get_contents("index.html"); or Using rewrite rules. So yourdomain.com/ will point to index.html but anything else points to processwires index.php (But I'd have to do some research to post a working anwer now ... just for inspiration) hah, just realized this is kinda solved ;P
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now