7

I have a laravel project, which is working fine on the local machine, where I have it set up on homestead, but when I have uploaded project to the production server on namecheap, none of the links or routes are working, I only get the index page open with no style, and if I click on any of the links I get 500 error. I have follow the suggested steps here:

So, my laravel project directory is in the same level as public_html, as well as public directory from my laravel project. They are all in the same directory level. And I have changed the paths in the index.php file:

require __DIR__.'/mariva/bootstrap/autoload.php';
$app = require_once __DIR__.'/mariva/bootstrap/app.php';

Then, I have changed the server.php inside the laravel project directory:

require_once __DIR__.'../public_html/index.php';

Permission were set apparently by the namecheap customer service, but I still get 404 error for all my css and js files, as well as when clicking on some html links on my page.

In the view file I am calling my css files like this:

<!-- CSS Files -->
  <link href="{{ asset('css/material-kit/css/bootstrap.min.css') }}" rel="stylesheet" />
  <link href="{{ asset('css/material-kit/css/material-kit.css') }}" rel="stylesheet"/>
  <link href="{{ asset('css/landing-page.css') }}" rel="stylesheet"/>

And js file the same way:

<!--   Core JS Files   -->
<script src="{{ asset('js/landing-page/jquery.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/landing-page/bootstrap.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/landing-page/material.min.js') }}"></script>

<!-- Control Center for Material Kit: activating the ripples, parallax effects, scripts from the example pages etc -->
<script src="{{ asset('js/landing-page/material-kit.js') }}" type="text/javascript"></script>

Not sure how can I fix that?

Update

I have managed to fix the css and js issue of not opening the files, I have moved the files to the wrong directory by mistake. But I still can't get any links on the page to work?

In my view I have links like this one:

<a href="{{ url('/login') }}">Login</a>

And when clicking on them I get 404 error.

Graham
  • 7,431
  • 18
  • 59
  • 84
Ludwig
  • 1,401
  • 13
  • 62
  • 125

3 Answers3

2

the problem may be in the trusted hosts

try setting this in your .env

APP_URL=http://
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
  • 1
    on the production env, not setting the APP_URL will result in 404 routes, that's weird but true! – behz4d Feb 07 '23 at 16:14
0

You need to set up Laravel project in shared hosting which is well explained here.

After you succeed thru all 7 steps your project should work fine on server.

Also add this to your .htacces file in public_html

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^ index.php [L]

Hope it helps

Graham
  • 7,431
  • 18
  • 59
  • 84
KuKeC
  • 4,392
  • 5
  • 31
  • 60
  • Have you copied all content of public folder from Laravel to hosting folder `public_html`? Don't override `index.php` and `.htacess` files. – KuKeC Jan 16 '17 at 14:50
  • I have copied all the content from public laravel folder to public_html folder, except for the .htacess file. I have modifed the existin .htacess file in public_html folder and added code you suggested, so it looks like this now: ```DirectoryIndex index.html index.php index.htm parking-page.html suPHP_ConfigPath /home/marigxwy/public_html Options +FollowSymLinks RewriteEngine On RewriteRule ^ index.php [L]``` But I still don't get any css and js links open. – Ludwig Jan 16 '17 at 15:05
  • Remove all code from `.htacces ` file and add just mine code – KuKeC Jan 16 '17 at 21:35
0

Options -MultiViews

RewriteEngine On
RewriteBase /laravel51/public/

# change above to your site i.e., RewriteBase /whatever/public/

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

In .htaccess file has to change