Skip to content

Remove /public in URL not working if using localhost #2930

Closed
@jlamim

Description

@jlamim

During the creation of examples for my book on CI4 and tutorials to help the Brazilian community, I came across the need to configure the URL so that /public is not displayed without changing the default framewoprk structure.

I created a .htaccess file at the root of the application containing the following code:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

When I use a virtual host (eg http://public-htaccess.test) this code in .htaccess works normally, but if I get the same structure of the application using localhost (http://localhost/public-htaccess ) the code does not work correctly, says that the controller was not found, as he understands that the controller is public-htaccess.

Could someone tell me if it is possible to do this redirection for the use case with localhost and how would it be the correct way within the framework standards?

The documentation in this regard is not clear, so if you can give me feedback on this issue, I can also supplement the documentation with this information.

OS: Win10
Apache: 2.4.41
PHP: 7.4.5
CodeIgniter: 4.0.3

P.S.: @lonnieezell and @samsonasik can you help me?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions