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

danimohamadnejad's avatar

How to use a PHP application under laravel?

Hi I have a Laravel project running good. Now I am adding a vanilla PHP project at "public/myproject" of Laravel project. I am trying to access php project like "http://domain.com/public/myproject" on live server and following is my public/.htaccess file which is default laravel htaccess file:

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

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

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

Problem is that I cannot access any laravel functionality in my php project since index.php file inside public folder is bypassed. How can I call my php project while preserving laravel app?

0 likes
5 replies
bobbybouwmann's avatar

I'm not sure if it's possible at all but I would advise against it.

Why don't you just use a subdomain and put your project in there? It doesn't make sense at all to have another application inside the directory of your main application.

3 likes
jlrdw's avatar

Is your vanilla PHP project a separate project, or is it meant to be part of the laravel project.

If part of, then convert to laravel code as needed, you can use the db facade for regular queries.

If separate, why put it under the laravel public folder. And just fyi, the htaccess file that comes with laravel already works. Like @automica mentioned, point to public as the document root.

2 likes

Please or to participate in this conversation.