โ˜• XOPSSCHOOL โ€” LEARNING MADE AFFORDABLE
Build the Skills Your Next Career Move Demands.
For the Price of One Coffee a Month.
Why spend hundreds on individual courses? Unlock an entire year of technical learning with one Coffee Pass.
US$4.90 /month
US$58.80/year
โ‚น499 + GST/month
โ‚น5,988 + GST/year
โ‚ฌ4.90 /month
โ‚ฌ58.80/year
12 Months of Access • Billed Annually • No Automatic Renewal
DevOps • Cloud • SRE • Kubernetes • Terraform • DevSecOps • AI • AIOps • MLOps • LLMOps • FinOps • GitOps • Platform Engineering & Much More
192
Premium Courses
1,085
Video Sessions
99
Ops Disciplines
86
Tool Courses
340
Assignments
227
Quizzes
โœ“ QR-Verifiable Certificates   โœ“ Learn at Your Own Pace   โœ“ Hands-on Learning   โœ“ New Courses Included
Learn from real-world, instructor-led video sessions by
Rajesh Kumar
Principal Architect • Trainer • Mentor • 15+ Years of Industry Experience
โ˜• Get My Coffee Pass โ€” Start Learning Today →
One Payment. Every Premium Course. One Full Year.
The best investment you can make is in the person you are becoming.

Laravel Tutorials: How to run Laravel Projects in Subdirectory

The issue you’re experiencing is common with Laravel applications when deployed in a subdirectory. By default, Laravel’s entry point is the public directory, which means you need to point your web server’s document root to the public directory of your Laravel application for it to work correctly. However, in a shared hosting environment or when working within a subdirectory, you may not have the flexibility to change the server configuration easily. Here are a couple of solutions to make your Laravel application

Option 1: Modify the .htaccess File

You can use an .htaccess file to rewrite URLs so that requests to https://www.bangaloreorbit.com/events/ are served by the public directory of your Laravel project. If you don’t already have an .htaccess file in your events directory, create one. Then, add the following rules:


<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1 [L,QSA]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Code language: PHP (php)

Option 2: Change Document Root (If Possible)

If you have access to modify the document root setting for your domain or subdomain (this is possible in some hosting environments), change the document root to point directly to the public directory of your Laravel application:

  • From: /home/professnow/public_html/orbit/bangaloreorbit.com/events
  • To: /home/professnow/public_html/orbit/bangaloreorbit.com/events/public

This change ensures that the web server serves the Laravel application directly from the correct entry point.

Option 3: Move Laravel Public Directory Content

If you cannot change the document root, another approach is to move the contents of the public directory to the root of your events directory and update paths accordingly. This method requires adjusting the index.php file in your new public location to correctly point to the autoload.php and app.php files.

  1. Move all files from public to the events root directory.
  2. Open index.php in the new location and update the paths to autoload.php and app.php to reflect their new paths.

For example, change:

Laravel index.php code changing bootstrap/app.php path from /../bootstrap to /bootstrap

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals

Related Posts

Apache: Comprehensive List of .htaccess Directives, Rules, and Commands

However, an โ€œabsolutely completeโ€ list is technically impossible to print here in fullโ€”because the .htaccess file can use nearly any Apache directive that is allowed by the…

Read More

How to Secure .git repo repository files and directory web inaccessible

Many times, people use git repository to host website in productions by clone-push-pull but it has one drawbacks, it appears the .git directory is accessible via the…

Read More

Apache non www to www config Setting

Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have…

Read More

Security practices for using git repository in production for deployment

Many times, people use the git repository to host websites in productions by clone-push-pull but it has one drawback, it appears the .git directory is accessible via…

Read More

Apaceh HTACCESS Tutorial

Introduction What Can I Do? Creating A .htaccess File What is .htaccess Why Not to use .htaccess Error Documents | Custom Error Pages Blocking users by IP…

Read More

Setup phpvibe and mediavide with subdirectory

To run PHPVibe in a subdirectory such as https://example.com/videos/ instead of the domain root, five settings have to agree: the folder name on disk, the .htaccess RewriteBase,…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Skylar Bennett
Skylar Bennett
4 months ago

A practical topic to include is how subdirectory deployments influence application portability across different environments. As projects move between development, staging, and production, inconsistencies in web server settings, asset paths, and routing configurations can become difficult to manage. Covering strategies for keeping these settings environment-agnostic would make deployments more predictable and reduce troubleshooting during future releases.

1
0
Would love your thoughts, please comment.x
()
x