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

admirhusic's avatar

Help with .htaccess

I need help tu setup the htaccess file. I have a webiste lets say mywebsite.com and I made a subdomain called laravel.mywebsite.com. Now in the root foolder of my C-Panel where i have a new folder for my subdmain. I want to put in this folder my laravel project without moving anything out of it. For example the file structure goes something like this: my_website/laravel.mywebsite.com/laravel_app. How to ajust the htaccess for this subdomain?

0 likes
2 replies
jlrdw's avatar
RewriteEngine On      //  Under this line
RewriteBase /laravel_app/    // add this line

//  also try 

RewriteBase laravel_app/    // no leading slash

I use a leading slash, and don't use a leading slash in routes, but whatever suits you.

You do not need to modify anything else in that file.

I don't think you will need the whole line laravel.mywebsite.com/laravel_app. But try it.

Note, at times a little old fashioned trial and error is okay.

admirhusic's avatar
admirhusic
OP
Best Answer
Level 3

Thank you @jlrdw for your response but it didn't work. I found the solution here:

https://blog.netgloo.com/2016/01/29/deploy-laravel-application-on-shared-hosting/

so my htaccess file looks like this now:


# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
   # Turn Off mod_dir Redirect For Existing Directories
  DirectorySlash Off
  # Rewrite For Public Folder
  RewriteEngine on
  RewriteRule ^(.*)$ laravel-test/public/ [L]
</IfModule>
# php -- END cPanel-generated handler, do not edit

If you visit larave-test.mywebsite.com you get the Laravel landing page

Please or to participate in this conversation.