2

I'm setting up a laravel 5.2 site with cpanel.

I have the domain root pointing to `public' and the site is working.

However for the home/index page it constantly shows public in the url and comes up with a page not found error.

so for my expected url I enter www.example.com and it comes up with www.example.com/public

If I navigate to an expected page e.g. www.example.com/production the page gets shown correctly and the url is presented correctly

I've got the site working correctly in homestead and I've created another site and that works fine - just can't work this out!

here's the contents of my .htaccess:

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

RewriteEngine On

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

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

This is the standard set up

very confused - what's missing - what can I test?

Ray
  • 3,018
  • 8
  • 50
  • 91

3 Answers3

0

You need to point web server to a public directory and restart it.

An example for VH:

DocumentRoot "/path_to_aravel_project/public"
<Directory "/path_to_aravel_project/public">
Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • Hi - yes I have already done that as mentioned and it is pulling it correctly from the public folder – Ray Aug 19 '16 at 11:14
0

I guess you need to add extra line into .htaccess file

RewriteCond %{REQUEST_FILENAME} !-d

So complete code will be

<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]

Ruhul Amin
  • 1,751
  • 15
  • 18
  • Hi- I think I already have that option included ? Do I need to duplicate? – Ray Aug 19 '16 at 11:15
  • are you using sub-domain or just domain? – Ruhul Amin Aug 19 '16 at 11:21
  • You can copy paste my code and try or follow here: http://stackoverflow.com/a/32580688/1960558 – Ruhul Amin Aug 19 '16 at 11:23
  • using the main domain – Ray Aug 19 '16 at 11:24
  • Hi - added your .htaccess code and no change. At the index page it still wants to add `public` to it - you can see here: www.spads-drama.org.uk it will add public to it and display a page not found error. If you replace public with productions it will show the correct page and correct url – Ray Aug 19 '16 at 11:44
  • as a workaround I've added a route to my `routes.php` to redirect to index as follows `Route::get('/public', function() { return redirect()->route('home'); });` this seems to work but not happy this is the right solution – Ray Aug 19 '16 at 11:49
0

Try this , move index.php from public to project root directory

modify index.php as

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

require __DIR__.'/bootstrap/autoload.php';
Sharad Kale
  • 971
  • 1
  • 7
  • 19