-1

I am using revolution slider in my Laravel website.When i removed the "/public" from the url using a .htaccess file in my root folder with this code:

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

RewriteEngine On

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 ^ server.php

The slider is not loading correctly anymore(no slider shown)
This is the html code:

<div class="topslider" style="margin-top: 80px;">
    <div id="slider">
        <div class="fullwidthbanner-container">
            <div id="revolution-slider">
                <ul>
                    @foreach($sliders as $slider)
                        @if($slider->type == 'video' && $slider->video && File::exists($slider->video))
                        <li {{-- data-transition="fade" data-slotamount="7" data-masterspeed="5000" --}}>
                            <video poster="" id="bgvid" playsinline="" autoplay="" muted="" loop="">
                                <source src="{{ asset($slider->video)}}" alt="" type="video/mp4">
                            </video>
                           {{--  <video src="{{ asset($slider->video)}}" type="video/mp4" playsinline autoplay muted loop> </video>  --}}
                            
                        </li> 
                        @endif
                    @endforeach
                </ul>
            </div>
        </div>

        <div class="tp-bullets">
            <div class="simplebullets round bullet">
                
            </div>
            
        </div>
    </div>
</div>

And finally this my website url

I get this error in my console:"Uncaught TypeError: Cannot read property 'nextElementSibling' of null"

Youssef Boudaya
  • 887
  • 2
  • 17
  • 29

1 Answers1

0

The standard .htaccess which comes with Laravel 5.4 is

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Try to replace your .htaccess file in public/.htaccess with this contents.

Content copied from https://github.com/laravel/laravel/blob/5.4/public/.htaccess

Donkarnash
  • 12,433
  • 5
  • 26
  • 37
  • i didn't change the .htaccess inside my public folder i kept it as it is.I added a .htaccess file in my root folder to remove the public/ from my url – Youssef Boudaya Dec 18 '20 at 10:36
  • The .htaccess in public folder is sufficient with the document root of the virtual host set to the project's public folder - no need for a separate .htaccess file in the root folder – Donkarnash Dec 18 '20 at 10:41
  • this is what i did https://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url – Youssef Boudaya Dec 18 '20 at 10:45
  • That is a very insecure way of hosting Laravel application in production. Best is to point the DocumentRoot for the virtual host configuration to the **public** folder of your project. That way only the public folder is accessible. Copying the .htaccess file in the root folder and setting the DocumentRoot to the project root folder makes the application vulnerable from security point of view and is not encouraged – Donkarnash Dec 18 '20 at 10:52
  • how can i do this "Best is to point the DocumentRoot for the virtual host configuration to the public folder of your project" – Youssef Boudaya Dec 18 '20 at 10:54
  • See this tutorial for how to setup virtual hosts on Apache https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart – Donkarnash Dec 18 '20 at 10:57
  • i do not have a sudo user on your server nor an Apache2 web server, – Youssef Boudaya Dec 18 '20 at 11:13
  • Which webserver you are using to host the site – Donkarnash Dec 18 '20 at 11:18
  • Is it shared hosting or vps? – Donkarnash Dec 18 '20 at 11:51
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/226129/discussion-between-youssef-boudaya-and-donkarnash). – Youssef Boudaya Dec 18 '20 at 11:53