davidxd33
davidxd33

Reputation: 1206

Routing to a directory outside of Laravel 4

I'm sorry if this is a very vague question, however I have found no other solutions on stackoverflow or the Laravel 4 docs.

I have the following directory structure

main / laravel

forums / forum installation

localhost points to main / laravel / public

I want to access the contents of /forums in my browser like localhost/forums however since a /forums does not exist in main / laravel / public it returns 404.

Now, I simply can just move the contents of /forums into laravel's public directory however I want to try to get laravel separate from other non-laravel directories like forum softwares and wiki softwares.


So to recap, localhost returns 404 when accessing /forums because localhost points to main / laravel / public and /forums is located outside of the laravel installation. I would like to have localhost/forums access the contents of ~forums and not search in ~main / laravel / public. If it's more logical putting ~forums in laravel's public folder, then please do explain to me because I've only been using laravel for around two months on one project.

Upvotes: 2

Views: 1562

Answers (2)

ptvty
ptvty

Reputation: 5664

Your web server's public directory has nothing to do with Laravel, it's not Laravel's public directory!

So IMO there is no problem to put other application's files in the public directory.

You can also create a separate directory for Laravel's public stuff and put that in your main public directory in order to keep things cleaner. You can simply change Laravel's public directory in bootstrap/paths.php file.

For example from

'public' => __DIR__.'/../public',

to

'public' => __DIR__.'/../public/laravel',

Upvotes: 0

msturdy
msturdy

Reputation: 10794

You can use an Alias in Apache to route a specific URL to a specific directory on the filesystem. For example:

server-wide (will apply to all VirtualHosts served by Apache)

Alias /forums /path/to/forums/install

or, for a specific VirtualHost:

<VirtualHost *:80>
    DocumentRoot /path/to/laravel/install
    ServerName your.domain.com
    CustomLog /var/log/apache2/access.log combined
    Alias /forums /path/to/forums/install
</VirtualHost>

Then anything incoming to localhost/forums will be served from that directory.

Upvotes: 1

Related Questions