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

Saj's avatar
Level 1

Laravel 5 - only home page route working on live server

i just found the main problem here. all is working fine in my localhost, but on live server, ONLY the home page route is working.

like : www.example.com/ is working all fine. BUT www.example.com/test is NOT working. and its only on live server, while all routes are working fine on localhost.

can you please tell me what is the problem, is there anything to do with the .htaccess file while uploading the project online, or there is anything else that I am missing?

0 likes
20 replies
jlrdw's avatar

Make sure that caps and small letters all correct I ran into this on a Windows test development all did work but linux is very case sensitive.

Saj's avatar
Level 1

I am using windows 8.1, its working fine.

and I have hosted my project on a cPanel sort of hosting. but its not working there, whereas all is working fine on my local machine with XAMPP.

tgif's avatar

same happened to me. I reinstalled all my php5 modules including mcrypt (which phpmyadmin warned me about) and it somehow fixed my problem.

Saj's avatar
Level 1

@csuarez can you please explain your answer, actually I dont know how to do it. installing php5 modules including mcrypt?

Saj's avatar
Level 1

one more thing i noticed. if I go to www.example.com/test is does not work BUT if i go to www.example.com/index.php/test , now it WORKS. So, now I tell you the directory sturcture: I have :

myWebsiteFolder/laravel/public_html so, I have all the laravel files to "laravel" folder and the "public" contents to "public_html" folder. my .htaccess file also lives in the "public_html" folder. do I need to fix my .htaccess file, if yes, how?

do you understand what is happening, I have been searching for my answer for last two days but failed.

Saj's avatar
Level 1

here is my .htaccess file. what changes should be made here?

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

    RewriteEngine On

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

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

jlrdw's avatar
jlrdw
Best Answer
Level 75

Here's mine and works:

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

    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]
</IfModule>

At least it's worth a try. Also make sure folder structures match on local and production servers.

8 likes
alrocha's avatar

Hi guys, I need some help, I'm uploading a project in Laravel 5 to a server. The main porblem is I just uploaded the project as localhost in public_html of my server, and I can access to my home page with www.domain.xxx/public, and I can't go any further, what should I change to just access to my home page using just the domain url?

Thanks in advance!

bobbybouwmann's avatar

@alrocha Please create your own thread ;) Not much users will look at this thread since it's already marked as solved!

1 like
tgif's avatar

@saj

sudo apt-get update
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt

then list the files in this directory: /etc/php5/apache2/conf.d

ls -la
lrwxrwxrwx 1 root root   32 Jun 17 00:56 05-opcache.ini -> ../../mods-available/opcache.ini
lrwxrwxrwx 1 root root   28 Jun 17 00:56 10-pdo.ini -> ../../mods-available/pdo.ini
lrwxrwxrwx 1 root root   29 Jun 18 21:58 20-apcu.ini -> ../../mods-available/apcu.ini
lrwxrwxrwx 1 root root   27 Jun 17 01:02 20-gd.ini -> ../../mods-available/gd.ini
lrwxrwxrwx 1 root root   29 Jun 17 00:56 20-json.ini -> ../../mods-available/json.ini
lrwxrwxrwx 1 root root   31 Jun 23 03:13 20-mcrypt.ini -> ../../mods-available/mcrypt.ini
lrwxrwxrwx 1 root root   31 Jun 17 00:56 20-mysqli.ini -> ../../mods-available/mysqli.ini
lrwxrwxrwx 1 root root   30 Jun 17 00:56 20-mysql.ini -> ../../mods-available/mysql.ini
lrwxrwxrwx 1 root root   34 Jun 17 00:56 20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini
lrwxrwxrwx 1 root root   33 Jun 17 00:56 20-readline.ini -> ../../mods-available/readline.ini

This is what mine look like.

tgif's avatar

@saj also forgot to mention - put php in your path

sudo nano /etc/bash.bashrc
//add this line
export PATH=/usr/lib/php5/:$PATH
//or wherever php5 is installed
jcehruraa's avatar

for live server www.mywebsite.com instead of mywebsite.com/public you don't need anymore to write public and also on to your links and script put public/ sample: public/assets/site/css/lightbox.min.css instead of: assets/site/css/lightbox.min.css

asaptra's avatar

Hi Guys,

You just need to enable rewrite mode:

sudo a2enmod rewrite

daniyalbutt01's avatar

i have the same problem. Where this file is created??? on laravel51 folder or in the public folder?

Massimiliano's avatar

Ok after hours working on this I found that for me the issue was that I needed to add to apache2.conf file in /etc/apache2 :

<Directory /var/www/html/my-site/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Otherwise .htaccess will be ignored (without AllowOverride All). After this modification, I could use the default .htaccess without any other issues, no need to edit anything.

Also, on 000-default.conf in etc/apache2/sites-enabled :

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/admin/public

Please or to participate in this conversation.