0

So, I've had some success after many errors, my current .htaccess looks like this:

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

RewriteEngine On


#Redirect URL
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [NC,L]


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

Before I would have to go to domain.uk/public/index.php

There's 2 issues i needed to fix, first to get rid of the index.php second to get rid of the /public

Now this code does that but the webpage is broken, no images, css, etc are loading but the site functions do work, I can login and work the page but it has no formatting... any ideas on how I can fix this?

Nazari
  • 438
  • 1
  • 9
  • 20
  • You don't need to edit the `.htaccess` and if you do that by `.htaccess` you will get more issue later on for example for accessing the assets – Nazari Apr 12 '20 at 17:30
  • @AlirezaNazari I had to change the htaccess file because the one provided was giving me a 500 internal server error and only allowing the site to be accessed via the index.php which caused loading issues – user3392493 Apr 12 '20 at 17:43

1 Answers1

0

Fist to remove the index.php you can use the following example:

Save this inside your .htaccess file:

Options +FollowSymLinks
RewriteEngine On

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

Or check this question

Second to remove the public folder you need copy the public folder inside your sub-domain root folder and then edit the path of files inside index.php, after that you need to move other files of your Laravel application to outside of your sub-domain root folder for my case laravel-app like /var/www/laravel-app and the root sub-domain folder for my example is like /var/www/html.

This is my laravel autoload.php:

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

for example to:

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

This is a app.php:

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

for example to:

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

By this example you can move your main application any where you want, I mean in unassailable place for public access.

Nazari
  • 438
  • 1
  • 9
  • 20
  • By this example you have your public folder separately as `html` and whole laravel application separately as `laravel-app` – Nazari Apr 12 '20 at 17:20
  • The only issue with this is, I purchased the code from CodeCanyon so if i ever wanted to update it would break all these changes... this would seem to fix the issue though but the dev would need to make these changes. – user3392493 Apr 12 '20 at 17:47
  • Also adding those changes to my htaccess file took me back to an internal server error 500, before the site was loading but just not the formatting and resources – user3392493 Apr 12 '20 at 17:48
  • I don't think change the path of `autoload.php` and `app.php` make issue for your application, by the way just you can try it at list, all Laravel applications are the same and that paths are just folder directory. – Nazari Apr 12 '20 at 17:52
  • I have been told doing this is not safe as the level above public should not be accessible to the public, only accessible by the application, this would also expose the .env file – user3392493 Apr 12 '20 at 17:57
  • Please make both changes to get the result, also double check your paths to be correct – Nazari Apr 12 '20 at 17:58