Set up front-end shop without '/public' in url

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 24 Jul 2019, 11:54

Hi guys!

My environment is the following:
Laravel Framework 5.8.26
aimeos-laravel 2019.07
PHP Version 7.2.19-1+ubuntu18.04.1+deb.sury.org+1

I am trying to set up front-end shop.

/var/www/schmuck/resources/views/app.blade.php :

Code: Select all

<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    @yield('aimeos_header')
    <title>Aimeos on Laravel</title>

    <link type="text/css" rel="stylesheet" href='https://fonts.googleapis.com/css?family=Roboto:400,300'>
    <link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    @yield('aimeos_styles')
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle Navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Laravel</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li><a href="/">Home</a></li>
            </ul>

            <div class="nav navbar-nav navbar-right">
                @yield('aimeos_head')
            </div>
        </div>
    </div>
</nav>
<div class="col-xs-12">
    @yield('aimeos_nav')
    @yield('aimeos_stage')
    @yield('aimeos_body')
    @yield('aimeos_aside')
    @yield('content')
</div>

<!-- Scripts -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
@yield('aimeos_scripts')
</body>
</html>
/var/www/schmuck/routes/web.php :

Code: Select all

Route::get('/', function () {
    return view('app');
});
But the /shop page looks like https://prnt.sc/ojdqis

It is because I removed 'public' from url (rename server to index and customize htaccess)

/var/www/schmuck/.htaccess :

Code: Select all

Options -MultiViews -Indexes

 

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_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]

 

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_URI} !^/public/

RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
As I see js scripts and other resources are not loaded, it tries to get it by http://schmuck/packages/aimeos/shop/the ... aimeos.css

What should I do ? Edit htaccess ?

I hope maybe I can set correct path somewhere in Aimeos config ?

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: Set up front-end shop without '/public' in url

Post by aimeos » 24 Jul 2019, 19:38

Your Larave ./public/ directory must be the document root of your domain - esp. for security reasons!
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 24 Jul 2019, 22:01

I have changed it safety. A lot of people remove that /public from url because it is ugly.
IT is worry that nobody can tell me how to solve the problem ?

User avatar
aimeos
Administrator
Posts: 7873
Joined: 01 Jan 1970, 00:00

Re: Set up front-end shop without '/public' in url

Post by aimeos » 25 Jul 2019, 06:40

Your Laravel ./public/ directory must be the document root of your domain. Set up your web server accordingly
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 25 Jul 2019, 07:23

Aaah, I understand ! Sorry, yesterday I was stupid a little bit )) So when I set public as document root then I will not have public in url and it will work. I have done it another way, you variant sure better!

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 25 Jul 2019, 07:55

Can you, please, explain why do I have this on /shop page ?

No catalog node for ID ""

https://prnt.sc/ojrtjz

I would like have like this:

http://laravel.demo.aimeos.org/default/en/EUR/list

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 25 Jul 2019, 11:36

I have fixed it just by adding demo data by executing

Code: Select all

php artisan aimeos:setup --option=setup/default/demo:1
, but footer is missing( What might be the reason ? Or the footer is just missing in template here https://github.com/aimeos/aimeos-laravel ?

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 25 Jul 2019, 12:08

Ok, now I am caring about how to remove '/shop' from url, or, I mean how to make application shows '/shop' content on '/' page ? So I want to show on my root / page the content from /shop

MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

Re: Set up front-end shop without '/public' in url

Post by MikaelNazarenko » 25 Jul 2019, 14:52

Nice, I have done it by adding the following code to my routes/web.php :

Code: Select all

Route::get('/', array(
    'as' => 'aimeos_shop_list',
    'uses' => '\Aimeos\Shop\Controller\CatalogController@listAction'
));

Post Reply