use a web host that allows you to place your application outside of the publically served folder
Laravel 8 on shared hosting server in subfolder
I am trying to move my local laravel 8 app to a shared hosting server. The server is in the address 'www.nameofsite.com'.
I need to put the application inside 'www.nameofsite.com/myapp'
I don't have public_html inside the 'www.nameofsite.com'.
Using FTP I created a folder called myapp inside the folder www. nameofsite. com; then I copied the local version of myapp inside this live myapp folder. I moved public folder to be at the same level as the application folder. At the moment i have the app setup in the following way:
|--- css, js, index.php, etc...
www.nameofsite--->myapp--->|
|--- myapp-> app, bootstrap, etc.....
I modified the index.php setting:
if (file_exists(__DIR__.'/myapp/storage/framework/maintenance.php')) {
require __DIR__.'/myapp/storage/framework/maintenance.php';
}
and I repeated the same operation for vendor and bootstrap in the index.php.
Now the problem: I launch the site going to 'www.nameofsite.com/myapp', the laravel 8 auth starts and it brings me to:
www.nameofsite.com/myapp/items/create
that is the form of creation of the item. As soon as I push the button SAVE of the form, I get the "Not Found The requested URL was not found on this server".
And the URL appearing in the address bar is:
www.nameofsite.com/items
(it lost the /myapp/ part)
In the web.php file I have a normal setup for the Items routing:
Route::post('/items','App\Http\Controllers\ItemsController@store')->middleware('auth','isAdmin');
and in the view i have:
<form method="POST" action="/items" class="mt-5">
@csrf
. .....
The .htaccess which is at the same level of index.php is the following:
Options -MultiViewsRewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
I can't understand why it behaves like this or why it jumps back to the "master" parent folder ('www.nameofthesite.com') when I do the POST action
Please or to participate in this conversation.