Bad Programmer
Bad Programmer

Reputation: 952

Laravel Project on Existing Website

I'm new to the Laravel framework. I am considering learning it and using it for a personal project, but as I am reading through the documentation I see that the web server document root would need to be set to the project folder.

Is it possible to integrate a laravel project with an existing webiste built with PHP and apache? For example, if I have a wordpresss install and wasn't using a framework but wanted tp create a subsite, I could just add more html and php files into a folder somewhere on the existing site or use a different vhost. Not sure if integrating would be so easy with Laravel,though.

Upvotes: 1

Views: 1377

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163758

Yes, it's possible. The solution I mentioned here should work for you.

To make it work you should modify both Laravel and Wordpress .htaccess files.

Laravel .htaccess example:

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

    RewriteEngine On

    RewriteCond %{REQUEST_URI} !^/blog/ # <=== NEW LINE!!!!

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]


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

Wordpress .htaccess example:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/   # <==== CHANGED LINE!!
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /blog/index.php [L] # <==== CHANGED LINE!!!
</IfModule>

Upvotes: 1

Related Questions