Welcome Guest, Not a member yet? Register   Sign In
Can't get rid of routing to "public"
#1

(This post was last modified: 03-15-2023, 02:06 PM by Tbronson.)

New installation of CI 4.3.2. with Bonfire 2. Trying to make this change to the home page URL

mysite.com/public TO mysite.com

Changed the document root to the "public" folder. Removed "public" from baseURL in .env and app/Config/App.php, leaving trailing slash.

Now, mysite.com gives a "404 Can't find a route for 'get: public'" error, and the URL in the browser address bar changes to mysite.com/public.

I've cleared every cache I can think of. Tried it in multiple browsers, on my Windows laptop and Android phone. 

These URLs work fine:

mysite.com/index.php // home page
mysite.com/admin // goes to Bonfire
mysite.com/home // I created a route to the "Home::index" in Routes.php

Exactly the same baseURL changes remove "public" no problem in another account in the same environment.

Any ideas?
Reply
#2

It seems your web server config is wrong.
Reply
#3

(03-15-2023, 10:12 AM)Tbronson Wrote: New installation of CI 4.3.2. with Bonfire 2. Trying to make this change to the home page URL

mysite.com/public TO mysite.com

Changed the document root to the "public" folder. Removed "public" from baseURL in .env and app/Config/App.php, leaving trailing slash.

Now, mysite.com gives a "404 Can't find a route for 'get: public'" error, and the URL in the browser address bar changes to mysite.com/public.

I've cleared every cache I can think of. Tried it in multiple browsers, on my Windows laptop and Android phone. 

These URLs work fine:

mysite.com/index.php // home page
mysite.com/admin // goes to Bonfire
mysite.com/home // I created a route to the "Home::index" in Routes.php

Exactly the same baseURL changes remove "public" no problem in another account in the same environment.

Any ideas?

I am not sure I understand what you did. What is the application structure now, and which directory on the server is accessed and which file is run when you open a browser at mysite.com? This does not make sense: "Removed "public" from baseURL in .env and app/Config/App.php, leaving trailing slash" - there is no "public" by default on $baseURL property in app/Config/App.php...

Anyway, in case you have not solved the problems yet: I have recently done some changes to Bonfire app links, so you may want to update the app and run it again.
==

Donatas G.
Reply
#4

@Tbronson Have you already found a solutions for yourself?
I have a similar problem. I use a subdomain, which points to the main folder and I can't get rid of the 'public' in the url.
Config/app $baseURL is the subdomain with trailing slash
public/htaccess: appstarter standard
Reply
#5

Normal server:

root
-- app
--system
-- public ( or public_html )
---- assets
------ css
------ js
------ etc;
-- writable

Sub Domain:
root
-- app
--system
-- public ( or public_html )
---- assets
------ css
------ js
------ etc;
-- writable


I'am on shared hosting and this has always worked for me.

I just FTP everything up to my server in the root and it just runs.
My Hosting provider is Web Hosting Buzz
As for php version I have a CPanel dropdown to select any version of php.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

I downloaded CI 4.4.8
Extract the .zip file
I went up to my domain meu.meusite.com.br (hostinger)
I configured my root directory to: meu.meusite.com.br/public
I configured App.php: public string $baseURL = 'https://meu.meusite.com.br/public/ (with and without slash)
I downloaded adminlte and within public I created the dist and plugins folders (adminlte)
Inside the VIEWS folder I created the admin folder and placed the dashboard.php file
and I created the templates folder (inside the VIEWS folder) with the following files: _footer.php, _header.php, _sidebar.php and admin_template.php.
When I type https://meu.meusite.com.br/ in the browser, the controller shows the VIEW but the ADMINLTE files that are in subfolders within /PUBLIC are not found.
href="https://meu.meusite.com.br/public/dist/css/adminlte.min.css" clicking on this link gives the error :Can't find a route for 'get: public/admin'.
What should I do?
In the browser console F12 presents some errors (8 errors): The resource “https://meu.meusite.com.br/public/dist/css/adminlte.min.css” was blocked due to the MIME type (“text /html”) does not match (X-Content-Type-Options: nosniff).
Reply
#7

You have configured it incorrectly. The public/ folder must be document_root on the server, it does not need to be specified for the site URL.
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#8

(This post was last modified: 08-11-2024, 07:40 AM by RRIOS.)

1-
class App extends BaseConfig
{
    /**
    * --------------------------------------------------------------------------
    * Base Site URL
    * --------------------------------------------------------------------------
    *
    * URL to your CodeIgniter root. Typically, this will be your base URL,
    * WITH a trailing slash:
    *
    * E.g., http://example.com/
    */
    public $baseURL = 'https://meu.meusite.com.br/'; In this line, if I kept the "string" an error appears in the editor "unexpected T_string , so I removed it. I tested with and without the "string"

2- and in my subdomain host configuration :
meu.meusite.com.br/public


When I look at the page source code and click on the address for the .css file this message appears. I opened another browser(EDGE) and the error persists.
Can't find a route for 'get: public/dist/css/adminlte.min.css'.
Reply
#9

public/dist/css/adminlte.min.css is wrong.
The URI does not exist, so web server passes the request to CI4, but there is no such a route.

The URI for the css file should be /dist/css/adminlte.min.css.
Reply
#10

(This post was last modified: 08-11-2024, 05:38 PM by RRIOS.)

Thanks so much !
I found the problem in the .env file that there is /public/ at the end of app.baseURL
Through your help I managed to solve
Thanks !
Reply




Theme © iAndrew 2016 - Forum software by © MyBB