Bump
Lumen works on shared web-host but isn't working?
Hi there, I'm new to Laravel and Lumen but I do understand that Lumen is a lot faster and more lightweight. That's exactly what I need for my budget/space and needs. So, I went ahead and uploaded Lumen to my web-host (I'm also running it on my local machine) with the "/public" removed and merged into the "root" (/). So, I assume I did it all correctly cause it's still working on my local machine. But, when I go ahead and run it on the web-host (my domain) cause I need an API (obviously) it doesn't work and I've tried everything. This is what I get: 404 ("Sorry, the page you are looking for could not be found."); you can see this in action at: https://api.friendifie.com/NewBlog/status (also note: the "root" (/) still runs though...).
Thanks in advance!
whats your webhost? shared or dedicated?
@GODCODE - I’m using x10hosting.com I’m not sure if you’d consider it shared hosting? It’s a free membership. So, I guess maybe shared but it’s only me who uses the account.
i think it is shared. i have tried to run a Laravel app on a shared. There was additional steps you take to make it work. Not sure in your case though since its a 404.
All over the internet and YouTube says we need to put the content of /public into our root / then we must edit a few files like the autoload, etc. to help guide the operations. Nothing worked then when I went ahead and fixed the paths so that it was correct then my routes didn’t work. I’ve even changed my PHP Version. My host has 7.1 they don’t classify if they’re running like 7.1.2 so I just selected the next version higher I think it’s 7.2 that way I’m not missing no new functions or components. I have PDO, BTstring and everything enabled. Nothing works. It sucks the community isn’t very helpful. I need this resolved. I’d hate to have to self-host my own website, that’s a lot of traffic and work.
do your routes all start with '/' in your routes file?
@SNAPEY - Hey, so here's some screenshots to help you see first-hand what's going on.
My local "/" works: https://i.imgur.com/ZnrOcZo.png
Showing you my "status" function which I've uploaded to my web-host using FTP and its live result: https://i.imgur.com/c2W4INx.png
Thanks!
probably an issue with .htaccess file
This is my current .htaccess file in the NewBlog I made to try and test everything.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
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_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Disable index view
Options -Indexes
# Hide a specific file
<Files .env.example>
Order allow,deny
Deny from all
</Files>
</IfModule>
I kept messing around and I think I got it working but now the only issue is:
Apparently I got it working now but it's forcing/showing my shared web-hosts path, I don't like that. It's a huge security risk for me. It's like:
https://api.mysite.com/home/myusername/public_html/another_folder/NewBlog/NewBlog
When I go to the root / it takes me to /NewBlog then once I replace the NewBlog it set with my route status or test it'll display their results on the screen.
Any advice? Thanks!
i just checked the setup of my Laravel 5.4 project in my shared hosting and the contents of the web hosting's public_html file are the contents of my Laravel 5.4's public folder. Then my main Laravel project directory is located where public_html is.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
php_value upload_max_filesize 10M
php_value post_max_size 10M
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/ [R=301,L]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [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>
I'll continue to check my project just in case something in there can help you...
@GODCODE - I’m not exactly too sure what I should do with that. Some of the content in your .htaccess file looks like it’ll cause some issues on mine because of “miss-matching”.
On my local machine the public folder can be how it’s suppose to be because when I run my project it’ll hide the public, but when I run it in my web-host it’ll show the public that’s why I took the .htaccess and index.php out of my public folder on my web-host.
Then in my / root index.php I fixed the bootstrap link then ran my project on my web-host.
I think it’s because of the DIR which seems to be deeply rooted into my Lumen Project NewBlog. 😭
Apparently I got it working now but it's forcing/showing my shared web-hosts path, I don't like that. It's a huge security risk for me. It's like:
https://api.mysite.com/home/myusername/public_html/another_folder/NewBlog/NewBlog
When I go to the root "/" it takes me to "/NewBlog" then once I replace the "NewBlog" it set with my route "status" or "test" it'll display their results on the screen.
Any advice? Thanks!
Please or to participate in this conversation.