Ci4 as RESTful with VueJs on IONOS Hosting | only home route accessable |
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!
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 Update the /kunden/homepages/41/d946984736068/htdocs/rest/index.php file: PHP Code: // Load our paths config file Update the /kunden/homepages/41/d946984736068/htdocs/rest/.htaccess file: Code: # If you installed CodeIgniter in a subfolder, you will need to |
Welcome Guest, Not a member yet? Register Sign In |