Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ted's avatar

Hi all,

I"m having similar kind of issue, I've tried above guidelines but didn't work for me.

I've started my project using Laravel, everything is working fine in my localhost (xampp), but when I've tried to host it, it's making me crazy. I've tried many guidelines in different forums..but didn't work any.

When I've hosted it, it's only showing home page and all other pages are broken. I'm assuming it's problem with htaccess file. As it seems it's unable to understand the page structure. (Also I've tried with a basic Laravel page, route is unable to load the controller method except homepage.)

Please help me to sort this out;

here's my configurations Host : digitalOcean shared hosting;

PHP version/OS : PHP Version 5.5.9-1ubuntu4.9;

I've given the 755 permission to /storage;

copy of htaccess
<IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
        Options -MultiViews
    </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]

######END###############

skliche's avatar

@ted Try this one:

DirectoryIndex index.php

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

    RedirectMatch 404 /\.git

    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    RewriteRule .? %{ENV:BASE}/index.php [L]

</IfModule>
ted's avatar

@skliche , thanks for reply but it didn't work.

I just found out that Digitalocean servers have the Nginx. somehow URL rewriting is not working there.

Previously I had a website in same server which was built on OctomberCMS. It worked perfectly. But this pure laravel application is not working at all.

theilen's avatar

Not sure if it helps, but for the shared hosting provider I use mostly (http://www.uberspace.de ), I have to change the .htaccess file from this:

[...]
RewriteEngine On
[...]

to this:

[...]
RewriteEngine On
RewriteBase \
[...]
jochantrelle's avatar

Greetings All,

Grateful for the tidbits from these convo threads. I got my deployment to work after the following steps.

  1. First and foremost, I zipped my project ( local server laravel/homestead, so to be clear I zipped my ~/code/[my project name] ).

  2. Uploaded the zipped project file (via GoDaddy's C-Panel) to the root (/home/my username/) and expanded it, so my Laravel project is on the same level with 'public_html'. NOTE, maybe I did something wrong, but none of my .dot files were brought over. So I had to manually, from within GoDaddy's FileManager '+File' in the corresponding directories and create both my .htaccess and my .env file, then copy past the contents from my local files. I suspect that will apply to any other .dot file I may need .git for example if thats even needed ( haven't run into that problem yet though).

  3. Here's where I think still needs improvement on my part. I then copied my entire public folder (from the newly expanded zip file) into the existing 'public_html' folder. I have seen advise from @lrobi2015 saying:

"I then delete the public_html dir and add a symlink to public in the laravel dir: ln -s laravel/public public_html and job done =) Cheers.."

Ok Great! Problem is, being that I am new to using Laravel's Framework and dealing with server side stuff manually, I had/still have no clue where the #$&% to perform/execute/paste the above symlink command. That said this is probably the correct thing to do as copying the contents of 'public' to 'public_html' is a violation of DRY (Do-not Repeat Yourself), plus the extra drama of having to code in 'public' and manually persist to 'public_html' is nonsensical. I a also not sure if when I figure this part out, If steps (4), (5) and (6) would still go as I have it, perhaps.

Finally (3) three file edits... since I haven't figured out the symlinks thing yet, I suppose.

  1. .HTACCESS

    Options -MultiViews

            RewriteEngine On
            # Redirect Trailing Slashes If Not A Folder...
            RewriteCond %{REQUEST_URI} !^public_html // <--- included this line
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)/$ public_html/$1 [L,R=301]     // <--- spliced in 'public_html' here
    
            # Handle Front Controller...
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
    </IfModule>
    
  2. AppServiceProvider (in the register method) $this->app->bind('path.public_html', function() { return DIR; });

  3. index.php. Amend the two lines below to reflect new folder structure IN THE index.php file under 'PUBLIC_HTML' not 'public': ⁃ require DIR.’/../[project name]/bootstrap/autoload.php'; ⁃ $app = require_once DIR.'/../[project name]/bootstrap/app.php';

DONE!

Along the way here, I was getting the blank page, then I was getting a huge, site not secure warning, then since I maintained 'DEBUG true' I started getting standard Laravel errors implying path problems locating app.blade.php (happy moment, something I recognized). Step 5 was actually the last thing I did during this journey and now my Site WORKS!!!....... so far.

I really hope this helps someone, and hey @JeffreyWay and @TaylorOtwell, I know this is a business (Laravel / Laracasts) however you guys have already been deemed as the Monks Of Code for all who use PHP, therefore not having some kind of lesson for newbies on how to do this is not cool (forgive me if I missed it, searched Laracasts + Googled extensively. No disrespect to your Forge utility, but some of us aren't doing enough volume yet to play with the big boys and fork out the $240 or thereabouts per year for that service. Love you guys I'm just saying, can't inspire the world and leave us hanging thats very Basquiat/Kurt Cobain'ish of you. LOL.

3 likes
mfakhrys's avatar

For those who still has this problem, use this to know the php error you have in your application. Copy and paste this at the top of your index.php in your public folder.

error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set("display_errors", 1);

From there, you can know the exact problem you have.

In my case I had this one

Call to undefined function Illuminate\Foundation\Bootstrap\mb_internal_encoding()

which brought me to conclusion that my server didn't have Mbstring PHP Extension installed (One of Laravel's server requirement). I enabled the extension, and voila, it's working now :)

2 likes
Previous

Please or to participate in this conversation.