There is a server on Xenial 16.04 , installed laravel , I redirect from /project_name/public to /project_name/ :
/etc/apache2/sites-available/project_name.conf

 <VirtualHost *:80> ServerAdmin admin@your_domain.com DocumentRoot /var/www/html/project_name/public/ ServerName your_domain.com ServerAlias www.your_domain.com <Directory /var/www/html/project_name/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/your_domain.com-error_log CustomLog /var/log/apache2/your_domain.com-access_log common </VirtualHost> 

/var/www/html/project_name/.htaccess :

 <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule> 

What did you do:
changed .htaccess :

 RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteCond %{REQUEST_URI} !project/public/ RewriteRule (.*) /project/public/$1 [L] 

and in the config:

 DocumentRoot /var/www/html/project_name/ Redirect permanent your_domain.com/ your_domain.com/public/ 

But all in vain.

  • one
    DocumentRoot /var/www/html/project_name/public/ site root. And opening the main site you get into this folder, and not in the project_name . You will not make a redirect in the project_name , since it is not accessible from the outside and this is correct. - Visman
  • @Visman I have already tried to change to /var/www/html/project_name/ - Tarasovych
  • one
    What for? Only public files should look into the world, everything else should be hidden. - Visman
  • @Visman but then the start page is not available by /project_name/ , but by project_name/public . I renamed server.php into index.php in the root of the project - it helped, but in this case, as far as I understand, all assets will need to be changed - Tarasovych

0