How to remove /public/ from URL

Mscv50

! 𝖎'𝖒 𝖜𝖆𝖙𝖈𝖍𝖎𝖓𝖌 𝖞𝖔𝖚 !
Babiato Lover
GiveAway Master
Trusted Uploader
Jan 10, 2020
3,712
18,803
113
🦇The Dark Night🦇
Read this:

3.4. Changing the public directory Important
Configure your web server's document / web root to point to the public directory of the software. For example, if you've uploaded the software in example.com folder, your web directory should be changed to example.com/public folder.
 
  • Like
Reactions: tanierlyons

Gitgitau

Member
Jan 25, 2021
112
14
18
Read this:

3.4. Changing the public directory Important
Configure your web server's document / web root to point to the public directory of the software. For example, if you've uploaded the software in example.com folder, your web directory should be changed to example.com/public folder.
I guess that's where I don't get it. where do you change the web root? in .env?
 

Mscv50

! 𝖎'𝖒 𝖜𝖆𝖙𝖈𝖍𝖎𝖓𝖌 𝖞𝖔𝖚 !
Babiato Lover
GiveAway Master
Trusted Uploader
Jan 10, 2020
3,712
18,803
113
🦇The Dark Night🦇
Maybe this will help :

Set your document root inside Apache's httpd.conf

Code:
DocumentRoot "/opt/lampp/apache2/htdocs/YOURPROJECT/public"
<Directory "/opt/lampp/apache2/htdocs/YOURPROJECT/public">

Or you will need to set the document root of your virtual host inside Apache's conf/extra/httpd-vhosts.conf

Code:
<VirtualHost *:80>
DocumentRoot "YOURPROJECTROOT/public"
ServerName yourproject.local
ErrorLog "logs/yourproject-error_log"
CustomLog "logs/yourproject-access_log" common
</VirtualHost>
 
Last edited:
  • Like
Reactions: tanierlyons

picassoo

Member
Jan 16, 2021
62
10
8
I am installing phpanalytics but I ended up having a /public/ after my URL. www.example.com/public/ how do I remove that? When you access the site withouth the /public/ you get a 404 error. Please help.

you need to create .htaccess and paste the code

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]

    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/$1

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php
</IfModule>
 

Gitgitau

Member
Jan 25, 2021
112
14
18
Maybe this will help :

Set your document root inside Apache's httpd.conf

Code:
DocumentRoot "/opt/lampp/apache2/htdocs/YOURPROJECT/public"
<Directory "/opt/lampp/apache2/htdocs/YOURPROJECT/public">

Or you will need to set the document root of your virtual host inside Apache's conf/extra/httpd-vhosts.conf

Code:
<VirtualHost *:80>
DocumentRoot "YOURPROJECTROOT/public"
ServerName yourproject.local
ErrorLog "logs/yourproject-error_log"
CustomLog "logs/yourproject-access_log" common
</VirtualHost>
Is there a simpler method to do this rather than using ssh putty
you need to create .htaccess and paste the code

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]

    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/$1

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php
</IfModule>
worked, thank you.
Is it a safe method? Read on a forum that it's not a safe method to use. Don't even know what that means.
 
  • Like
Reactions: picassoo

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu