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

tisuchi's avatar

Upload project in Cpanel

Hello I have created a project with Laravel 4. Now I wan to upload this project in Cpanel. There are few issues here-

  1. I want to use a sub directory to upload my project. Let's say, example.com/laravel I want to upload my project in laravel folder.

  2. In my hosting, I have few more websites are hosted. So, I don't want to make bother others.

Can any experts help me to do so?

0 likes
11 replies
theUnforgiven's avatar

You will need use htaccess for this, if you search around the net you will find plenty of solutions and options.

bashy's avatar

What web server software is running on cPanel? You will need to setup some sort of rewrite so /laravel shows /laravel/public

You can also get your host (or you if you have SSH access) to make a symlink that links /laravel to the laravel public folder

tisuchi's avatar

@bashy

Thank you for your replay. I don't know what web server is running on cPanel. I providing my web ip address- 192.69.210.146

I using cPanel shared hosting package.

May I know the process of rewriting please?

bashy's avatar

Think it might be running Apache. Do you see that anywhere? I just ask since I've seen LiteSpeed on Cpanel before.

Rewrites are done with .htaccess (wouldn't recommend but does work)

What I would recommend is creating a symlink to point to your laravel's public folder.

Symlink: /public_html/laravel -> /laravel/public

christopher's avatar
Level 30

@bashy no.

cPanel is running Apache. Just put this into your .htaccess file

RewriteEngine On
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteRule ^(.*)$ public/$1 [L]

Then your domain is routed to the public folder and you dont have to type domain.com/public.

bashy's avatar

@hostianer How does that make laravel a sub directory? What you put isn't for what they want (and is also open to security holes).

yayuj's avatar

.htaccess in the public_folder may not work. The best alternative is for you to contact the hosting company and ask to them to change the document root to /public_html/public. It will, for sure, work.

bashy's avatar

@yayui Also not right, he wants laravel in a sub directory (including other content on the domain)

example.com/index.html

example.com/laravelsite/blog

yayuj's avatar

@bashy - My bad, I didn't knew that. I thought that he wanted to add the public folder as the document root.

henrique's avatar

Adding to @bashy answer, if you don't have ssh access, you might be able to create a symlink using php, just create a php with

symlink($targe, $link);

And it should work. I had to do this on one hosting (not Laravel related though).

jekinney's avatar

I upload the files via ftp to a directory with in the root (usually something like html_www, but depends on host). Very important is to manually set folder and file permissions otherwise you will leave the files open for access which isn't good. Great your sub domain through the cpanel. Forward the sub domain to the public folder.

Note: This isn't the best solution due to security reasons, but it works. Typically you only want the contents of the public directory in your root. But many shared hosting providers don't bother help you set up the proper way and allow you to over ride the htaccess or PHP.ini files.

Please or to participate in this conversation.