0

I followed steps on this: http://laravel.io/forum/12-29-2015-hosting-laravel-5-on-subdomain

/home->laravel-ecommerce contains all laravel files except public (see above link)

structure on server:

enter image description here

public_html->laravel-ecommerce contains:

enter image description here

my .htaccess looks like :

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

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

I am getting HTTP ERROR 500.

I don't want to move all files in public folder to main directory as it may people many be able to access other files hence security compromise. Then there is no point using laravel.

Is there any easier way to point the sub domain to laravel-ecommerce/public folder.

Thanks!

Edit:

I am hosting on hostgator.

Index.php:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/

require __DIR__.'/../../laravel-ecommerce/bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../../laravel-ecommerce/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

autoload.php

<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/../laravel-ecommerce/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/

$compiledPath = __DIR__.'/../laravel-ecommerce/cache/compiled.php';

if (file_exists($compiledPath)) {
    require $compiledPath;
}

app.php

<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../laravel-ecommerce/')
);

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    App\Http\Kernel::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;
Phoenix
  • 332
  • 2
  • 9
  • 32

2 Answers2

0

Try htaccess code to redirect for subdomain:

#htaccess redirects for subdomains
RewriteRule ^subdomaindirectory$ subdomaindirectory/ [R,L] 
RewriteRule ^subdomaindirectory/(.*)$ subdomaindirectory/$1 [L]

Note Replace subdomaindirectory with your folder name.

Further, Could you please place your server error log?

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
  • My log is showing logs from localhost wamp server. My log is dated 6 December. No log for today – Phoenix Dec 20 '16 at 09:47
  • Can you suggest a better way to put localhost project onto server – Phoenix Dec 20 '16 at 09:49
  • @Phoenix I think [Uploading Laravel Project onto Web Server](http://stackoverflow.com/questions/22075238/uploading-laravel-project-onto-web-server) will help you for **Can you suggest a better way to put localhost project onto server** – AddWeb Solution Pvt Ltd Dec 20 '16 at 10:03
  • I did that via filezilla – Phoenix Dec 20 '16 at 10:04
  • Ok, No Worries! Just read [this document](http://www.stephensaw.me/deploy-laravel-on-shared-hosting-with-subdomain/) start from **Update the Index.php** point and check with your one. Hope this get resolved. – AddWeb Solution Pvt Ltd Dec 20 '16 at 10:16
0

Since your .htaccess file is not in the root directory, you have to use RewriteBase. Add RewriteBase / after RewriteEngine On

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

RewriteEngine On
RewriteBase /

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
africpoet
  • 61
  • 1
  • 5