Ilija Petkovic
Ilija Petkovic

Reputation: 143

Change .htaccess file in laravel 4

I have a problem when upload laravel project on my shared hosting. On that hosting I have two addon domains with separate folders in document root. But when I put laravel project in document root and move everything from public folder in root to remove that "/public" from url, I cant access to my addon domains. I'm getting 500 Internal service error. When I remove .htaccess file I can access to my other domains, but I can't access to my Laravel project. How can I change default laravel .htaccess file?

Upvotes: 1

Views: 1954

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

Well, you should not move everything from public folder, this is a very important part of your Laravel application, it was built this way to separate your application source code from the public files anyone can access, if you make your application root also your public folder, anyone will be able to access any php files from your application, and this is so unsafe...

What you need to do is to point your document root to /serverRoot/applicationRoot/public.

If you really cannot do that, I'm afraid you'll have to edit index.php and try to change thos two lines:

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';

to

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/start.php';

And see if it works for you.

EDIT

Laravel's default .htaccess file is there just for rewriting your URLs, so you dont see aindex.php` on them. Basically it does 2 things:

1) If you access your site using http://www.site.com/, internally it will point to http://www.site.com/index.php.

2) When you access your site using http://www.site.com/index.php it hides the index.php part.

This is kind of recursive, because the first step leads to the second one.

Now you have to think and see how this is conflicting with your other domains, because the files you are serving in those domains matters and since we are not aware of what they are, helping more is kind of difficult.

Upvotes: 2

Related Questions