skip to Main Content

I have a Laravel 6 app which is working fine locally on redhat apache.

my client setting the domain and must using /abc ater the domain
i.e domain.or/abc

i put my root folder into /var/www/abc/

In config/app.php I have

‘url’ => ‘h t t ps :// domain.or/abc’,

In pfi/public/.htaccess I have

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

    RewriteEngine On  
    RewriteBase /abc

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

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

I can access domain.or/abc and the page loads (without styles, images, …). But all the other links to pages, images, css, js, … are wrong. For example, they link to

domain.or/css/style.css

instead of linking to

domain.or/PFI/css/style.css

i.e., "PFI" is missing from all the links.

If I go to

domain.or/abc/login

i got 403 error, but if domain.or/login, page load without css,js

and if i open css,js file manually by copy the link to the new tab
i.e domain.or/abc/css/style.css the css dont load, it only show the main page instead of css scripts

2

Answers


  1. Chosen as BEST ANSWER

    I got the answer

    The changes i did:(my apps folder is laravel)

    1. create folder on /var/www/ same with ur subfolder domain, sudo mkdir PFI
    2. Create softlink: ln -s /var/www/laravel/public /var/www/PFI
    3. Update httpd.conf

    <VirtualHost *:80>
        ServerName xxxx
        DocumentRoot /var/www/PFI
        Redirect permanent / https://xxx/PFI
    
    <Directory /var/www/laravel/public>
            AllowOverride All
        </Directory>
    </VirtualHost>
    
    <VirtualHost _default_:443>
    ServerName XXX
    DocumentRoot /var/www/PFI
    </VirtualHost>

    1. update on my layouts with
    2. and all my css,js change to <href ="css/style.css">

  2. in order to fix this issue:

    1. ensure that inside .env file APP_URL=https://domain.or/PFI
    2. ensure the same for config/app.php file 'url' => env('APP_URL', 'https://domain.or/PFI'),
    3. edit your public/index.php you have to change the path of these to line to be consistent with the actual path
        $app = require_once __DIR__.'/../path_to_public_folder/bootstrap/app.php';
        
        require __DIR__.'/../path_to_public_folder/vendor/autoload.php';
    
    
    1. in .htaccess
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        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_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
        
        # Redirect http to https 
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    
        <IfModule mod_headers.c>
            # Prevent click jacking
            Header set X-Frame-Options Deny
            Header set X-Frame-Options: SAMEORIGIN
        </IfModule>
    
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search