SOLVED Subdomain displays /public how to remove?

Mohit Shrestha

Registered
Jul 28, 2018
1
0
1
INDIA
cPanel Access Level
Website Owner
Hello Everyone, I am quite new to C-panel, so bare me if its quite a simple problem.
I have created a subdomain say xyz.domain.com and redirected it to my AWS elasticbeanstalk DNS .

Now when hit for my subdomain "xyz.domain.com" it shows "xyz.domain.com/public/"
I want it to be like "xyz.domain.com" , please help me out !
 

24x7server

Well-Known Member
Apr 17, 2013
1,911
96
78
India
cPanel Access Level
Root Administrator
Twitter
Hi,

What is the redirection code you set? Can you share it here with us?
Also, can you check if the document root of the subdomain is properly met and that there is no additional redirection codes in any .htaccess file?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,255
313
Houston
Hi @Mohit Shrestha

As suggested by @24x7server more information on how you're redirecting the domain would be helpful. Also, the domain's documentroot would also be useful in identifying why that's occurring.

Thanks!
 

Ahmed2208

Registered
Feb 17, 2020
2
0
1
Bangladesh
cPanel Access Level
Root Administrator
My subdomain directory is like "public_html/test" . I have uploaded my laravel project in test by unziping. I also cut all files from public and pasted here. My .htaccess is something like

Code:
<IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On
    RewriteBase /
</IfModule>
Now, my index file is something like this,

Code:
*
 * @package  Laravel
 * @author   Taylor Otwell <[email protected]>
 */

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

/*
|--------------------------------------------------------------------------
| 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 great to relax.
|
*/

require __DIR__.'/../vendor/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__.'/../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);
But, when I click test.xyz.com. URL takes me to test.xyz.com/public/public. Any solution?
 

Ahmed2208

Registered
Feb 17, 2020
2
0
1
Bangladesh
cPanel Access Level
Root Administrator
Brother solved it,
  1. renamed server.php to index.php
  2. made an .htaccess in the directory with
Code:
Options -MultiViews -Indexes

 

RewriteEngine On

 

# Handle Authorization Header

RewriteCond %{HTTP:Authorization} .

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

 

# Redirect Trailing Slashes If Not A Folder...

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} (.+)/$

RewriteRule ^ %1 [L,R=301]

 

# Handle Front Controller...

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]

 

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_URI} !^/public/

RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
  1. Then, in the public directory made the directory 2 steps before. something like
Code:
require __DIR__.'/../../test.xyz.com/vendor/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__.'/../../test.xyz.com/bootstrap/app.php';
TADA ! It worked.