Welcome Guest, Not a member yet? Register   Sign In
Ci4 as RESTful with VueJs on IONOS Hosting | only home route accessable
#1

(This post was last modified: 08-17-2023, 06:40 AM by De0x95.)

Hello Guys,
im new to the entire CodeIgniter bubble, as well as hosting, routing, networking etc.. so please bear with me.
Im developing a Website (Frontend VueJs, Backend Ci4 RESTFul (no views)) and I will be deploying it on an IONOS (1&1) Dedicated Server (managed).

When I connect to the server via FileZilla, the root is structerd like:
"ExampleWebsite" <- www.example.de/
"BETA_ExampleWebsite" <. www.beta.example.de/
"logs"

Currently I have the vue app inside the "BETA_ExampleWebsite" folder which is working fine.
In this folder there is another subfolder called "REST", inside this folder the entire ci4 installation is located.

Now, if I navigate to "www.example.de/REST/public" the "$routes->get('/', 'Controller::Method')" is accessed as expected.
But if I try to navigate to any other route like "$routes->get('/blog','Blog::index')" I get a 404 response.

This is also true for any axios.get requests made from VueJs.

The .env file has "app.baseURL = 'http://beta.example.de'"

Again, as I said, my knowledge about this entire topic is very limited to say the least, can anyone help me with that?

Also, I think that the ci4 installation should be outside of the "BETA_ExampleWebsite" folder so it cant be reached through the browser am I wrong?

BTW: when i connect to the server via SSH the mentioned above folders are at the following directory:
"/kunden/homepages/41/d946984736068/htdocs/"

If you guys need any more information im happy to provide it. Thanks in advance!
Reply
#2

(This post was last modified: 08-18-2023, 04:09 AM by sammyskills.)

While I don't know how your server is configured, here are some of the things I think you should consider.

Since your CI4 installation is in a subfolder, your app.baseURL value should also reflect that, like so:
Code:
app.baseURL = 'http://beta.example.de/rest/'

Quote:Also, I think that the ci4 installation should be outside of the "BETA_ExampleWebsite" folder so it cant be reached through the browser am I wrong?
You're not wrong. I suggest you move the CI4 installation out of the htdocs folder, somewhere in this folder: /kunden/homepages/41/d946984736068/. Let's assume you create a folder there named rest-core, then you can move the CI4 installation files and folders except the public folder to the newly created rest-core folder.

The public folder is meant to be the “web root” of your site, and your web server would be configured to point to it. See docs. So, assuming that you don't have virtual hosts configured in your server, you would upload all the files and/or folders in the public folder to your /kunden/homepages/41/d946984736068/htdocs/rest/ directory. So you would have something like this:
Quote:/kunden/homepages/41/d946984736068/htdocs/rest/index.php
/kunden/homepages/41/d946984736068/htdocs/rest/.htaccess
/kunden/homepages/41/d946984736068/htdocs/rest/favicon
/kunden/homepages/41/d946984736068/htdocs/rest/robots.txt

Update the /kunden/homepages/41/d946984736068/htdocs/rest/index.php file:
PHP Code:
// Load our paths config file
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH '../app/Config/Paths.php'// change this line to: require FCPATH . '../../rest-core/app/Config/Paths.php';
// ^^^ Change this line if you move your application folder 

Update the /kunden/homepages/41/d946984736068/htdocs/rest/.htaccess file:
Code:
# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
RewriteBase /rest/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB