1
votes

I have created a laravel project and upload to the server like https://www.mydemosite.org/healthcard

And i uploaded all the files to the sub directory "healthcard". Now i have done the changes in the public folder.

  1. move all the files from public folder to "healthcard" folder.

  2. Change the index file as this

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

after this i added a .htaccess file to root

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

And in public folder like this

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On    
    RewriteBase /healthcard/

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

I have changed the .env file also like

APP_URL=https://www.mydemosite.org/healthcard

but still it is not working. Should i do any other changes. Please let me know. Advance thanks for help.

2
This is definitly not an easy config. Just a question: Can you not make it a subdomain? Like healthcard.mydemosite.org? That is usually easier.Rob Biermann

2 Answers

1
votes

For a similar project i have this as the root .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

And this in the public folder:

<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}]
</IfModule>

It's a copy paste I got from elsewhere, so I can't really give you more details, but it's worth a try...

Also: try to revert your index.php back to what it was originally and place it back into the public folder (in fact place all files you moved out of the public folder back in.)

0
votes

Please do the following in order

  1. Extract all your files in In the folder with name local located in the public_html

  2. Move The files in the public folder to the public_html next to the local folder.

  3. Open the index.php file

change this line:

require __DIR__.'/../vendor/autoload.php';

to this:

require __DIR__.'/local/vendor/autoload.php';

and same for this :

$app = require_once __DIR__.'/../bootstrap/app.php';

change to this:

$app = require_once __DIR__.'/local/bootstrap/app.php';
  1. Open the .env file and set your database info
DB_DATABASE=YOUR_DB_NAME
DB_USERNAME=YOUR_DB_USERNAME
DB_PASSWORD=YOUR_DB_PASS
  1. Be sure to check the file below as it sometimes changes when extracting its content. So replace its content with this codes
    <IfModule mod_rewrite.c>
        <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]
    </IfModule>
  1. Check php version installed on your server or shared hosting that must be conforms with laravel required version.