Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel and Wordpress on same server/domain

I am trying to host a WordPress site inside a Laravel(5.1) project. I have the following structure (stripped down some)

├── app
├── config
├── public
│   ├── index.php
│   ├── wordpress -> ../wordpress
│   └── .htaccess
├── resources
├── storage
├── vendor
└── wordpress
    ├── index.php
    ├── wp-admin
    ├── wp-config.php
    ├── wp-includes
    └── .htaccess

The vhost document root is public.

The Wordpress should catch everything that falls through the .htaccess. But for example /login should go to laravel. When my project grows i intend to add more rules to catch requests for Laravel. I have the following .htaccess file in /public:

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

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule "^/login" "index.php" [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule "^(.*)$" "wordpress/$1" [L]
</IfModule>

But when i make the request to /login i still end up with the wordpress page. Here is a part of the log:

 add path info postfix: /var/www/public/login -> /var/www/public/login/
 strip per-dir prefix: /var/www/public/login/ -> login/
 applying pattern '^/login' to uri 'login/'
 add path info postfix: /var/www/public/login -> /var/www/public/login/
 strip per-dir prefix: /var/www/public/login/ -> login/
 applying pattern '^(.*)$' to uri 'login/'
 RewriteCond: input='/var/www/public/login' pattern='!-d' => matched
 RewriteCond: input='/var/www/public/login' pattern='!-f' => matched
 rewrite 'login/' -> 'wordpress/login/'
 add per-dir prefix: wordpress/login/ -> /var/www/public/wordpress/login/
 strip document_root prefix: /var/www/public/wordpress/login/ -> /wordpress/login/
 internal redirect with /wordpress/login/ [INTERNAL REDIRECT]

It seems like the rewriting does not stop at the [L] flag.

like image 622
Niek de Gooijer Avatar asked Nov 26 '15 13:11

Niek de Gooijer


People also ask

Can I integrate Laravel with WordPress?

Fortunately, one of the most popular Hypertext Preprocessing (PHP) programming frameworks, Laravel, can be integrated with WordPress. This combination can enable you to manage your web application development through the WordPress back end, offering a more streamlined workflow.

Can you run Laravel on shared hosting?

Developers opt to deploy Laravel on shared hosting mainly for cost savings. Shared hosting is cheap and is generally preferred by those unaware of its detriments. Similarly, developers generally install and deploy Laravel to shared hosting without considering the problems it causes for the end-users.

Which server is best for Laravel?

A2 Hosting – Best Laravel Hosting for Speed. InMotion Hosting – Best Hosting for Basic Websites for Laravel. Liquid Web – Best Dedicated Hosting for Laravel. Cloudways – Best Cloud Hosting for Laravel.


1 Answers

Ended up asking the same question on ServerFault. There i got the answer. Linking it here for refference:

https://serverfault.com/questions/739728/laravel-and-wordpress-on-same-server-domain

like image 98
Niek de Gooijer Avatar answered Oct 16 '22 20:10

Niek de Gooijer