skip to Main Content

I want to remove /public in the URL i want to use virtual host not changing server.php into index.php.

i’m useing webuzo admin panel i add this lines to apache config file
but it seems its not working
please help me what should i do

my server is centOs 7 and my project is on laravel 5.8

<VirtualHost *:80>
ServerName uptodate.pnashr.pub

ServerAdmin [email protected]
DocumentRoot /home/uptodateadmin/public_html/public

<Directory /home/uptodateadmin/public_html/public>
    Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
</VirtualHost>

3

Answers


  1. I have testing your VirtualHost config, nothing wrong with that code.

    You have to make sure your public .htaccess is default from laravel and not deleted. Webuzo will already regenerate VirtualHost config everytimes we add new domain or subdomain web. So set document root from webuzo admin panel not change manually from apache config file.

    Actually VirtualHost not change server.php to index.php but server.php
    located at parent directory and document root at subfolder public.

    You can make server.php file and include “../server.php”; inside that file

    Don’t forget to check you .htaccess. Just use default .htaccess from laravel

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        RewriteEngine On
    
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    
    Login or Signup to reply.
  2. so you want to make laravel for share hosting its easy

    make a folder with any name in my case its root

    move all data to root except public folder

    now rename your public folder with public_html

    your file structure should look like this

    enter image description here

    now open public_html/index.php define your bootstrap and autoload
    page should look like this or you can copy all code from here

    <?php
    
    /**
     * Laravel - A PHP Framework For Web Artisans
     *
     * @package  Laravel
     * @author   Taylor Otwell <[email protected]>
     */
    
    define('LARAVEL_START', microtime(true));
    
    
    
    require __DIR__.'/../root/vendor/autoload.php';
    
    
    
    $app = require_once __DIR__.'/../root/bootstrap/app.php';
    
    // set the public path to this directory
    $app->bind('path.public', function() {
        return __DIR__;
    });
    
    
    $kernel = $app->make(IlluminateContractsHttpKernel::class);
    
    $response = $kernel->handle(
        $request = IlluminateHttpRequest::capture()
    );
    
    $response->send();
    
    $kernel->terminate($request, $response);
    
    

    that’s it now your public_html is public for users
    root file should be in back because this files should not expose to public

    Login or Signup to reply.
  3. In Webuzo you can change the document root at:

    /usr/local/apps/apache/etc/conf.d/webuzoVH.conf
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search