0

I'm working on a project divided into two separate parts. Part one, the bigger part, is in Laravel 4.2. Part two, the shorter part, is in Laravel 5. Both are on the same server.

My goal is to access and use the routes of the both projects i.e Project 1 can call and access the routes of Project 2 and vice versa.

What I'm doing, to acess both projects, is using the following Virtual Host file:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/Laravel4Project/public

    ServerName www.Laravel4Project.dev
    Alias /billing /var/www/Laravel5Project/public

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/Laravel4Project/public/>
        AllowOverride All
    </Directory>
</VirtualHost>

The '/billing' Alias in above file let me allow to access the Laravel5Project from within Laravel4Project without declaring a '/billing' route in my Laravel4Project's 'routes.php' file. Sessions and authentication is fine. No problem till here.

The problem is that the 'billing' Alias points to '/' root in Laravel5Project and there are some other routes in my Laravel5Project as given below:

Route::get('/', function() {
    return 'Laravel 5 Project';
}

Route::get('/anOtherRoute', function() {
    return 'Another Route from Laravel 5 Project';
}

To access the '/' route of Laravel5Project, I provide the '/billing' link in my Laravel4Project which works fine and let me access the Laravele5Project. But to access the '/anotherRoute' of Laravel5Project when I provide '/billing/anotherRoute' or '/anotherRoute' link in Laravel4Project both don't work and Apache Server gives me the following error:

Not Found
    The requested URL /billing/anotherRoute was not found on this server.
    Apache/2.4.12 (Ubuntu) Server at www.laravel4project.dev Port 80

I know this is because in my Laravel4Project there is no route '/billing/antohterRoute/' but it is in Laravel5Project's 'route.php' file. '/billing' itself is not a route, it's just an 'Alias'.

So my question is How can I access all the routes of Laravel5Project from within Laravel4Project and vice versa?

Following are given the .htaccess files of both Laravel4Project and Laravel5Project:

.htaccess File in Laravel4Project Root Directory:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond  %{REQUEST_URI}  !^/mm.*$
    RewriteRule ^(.*)$ public/$1 [L,QSA]

    RewriteCond  %{REQUEST_URI}  ^/mm.*$
    RewriteRule ^/mm/(.*)$ public/mm/$1 [L,QSA]
</IfModule>
AddDefaultCharset utf-8

.htaccess File in Laravel4Project 'public' Directory:

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

    RewriteEngine On

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

.htaccess File in Laravel5Project public Directory:

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

    RewriteEngine On

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

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

1 Answer 1

0

After waiting a lot for a response from the Laravel Community and stack exchange as well I couldn't get the answer.

But I also kept try myself to find the solution and here it is:

If you note in the question above I've mentioned that Apache gives me the following error:

Not Found
The requested URL /billing/anotherRoute was not found on this server.
Apache/2.4.12 (Ubuntu) Server at www.laravel4project.dev Port 80

Note the URL "/billing/anotherRoute" and the Domain "www.laravel4Project.dev". It means the URL I was giving was wrong as given below:

Wrong URL

www.laravel4project.dev/billing/anotherRoute

Just add "index.php" after "/billing". So the correct URL would be as given below:

Correct URL

www.laravel4project.dev/billing/index.php/anotherRoute

Now the only problem remaining here is to get rid off and remove the 'index.php' from the URL.

Can some one plz help me on this?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .