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

almazik's avatar

Deploying app to shared hosting - .htaccess problem

Hi everyone

I am in need to make the laravel app live on shared hosting and can not use Laravel forge at this time. So I uploaded my app files over ftp to public_html/new/ directory.

when I navigate to site.com/new/public I'm getting 500 error

My .htaccess file is like this

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteBase /new

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

any ideas, please, here?

0 likes
8 replies
trthanhbk's avatar

Put .htaccess inside "public_html/" with below content:

# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change site.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/new/public/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /new/public/$1
# Change site.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteRule ^(/)?$ new/public/index.php [L]

in folder "public_html/new/public" keep default .htaccess of Laravel.

--> Now you can try to connect to "site.com" to see the result :)

1 like
almazik's avatar

@trthanhbk thanks for the reply. But it's not working, it's now giving 500 error on site.com

p.s. if it's relevant - I'm running Apache/2.2.16 (Debian)

almazik's avatar

@Prez Thanks for your input. you are right, I will need to do this, I'm just now trying to make new site working, while I need to preserve old site to be functioning during I'm testing new one. And the old one is located in public_html

jlrdw's avatar

Your url

site.com/newsite/public

then shouldn't the htaccess be

RewriteBase /newsite/
#  not
RewriteBase /new
almazik's avatar

@jlrdw thanks. no, it's actually new, not newsite. misspelled it here, edited now

almazik's avatar

thanks everybody for you replies. after struggling with this a couple more days I've convinced the client to leverage Digital Ocean and now this is just great

Please or to participate in this conversation.