简体   繁体   中英

Laravel home page gives 404 but index.php works

I'm creating a custom cms in a subfolder of my site. I installed a fresh copy of laravel at www.mysite.com/cms/ <-- application, bundles, public, etc are there.

I can not make a virtual host due to shared hosting but I managed to remove the need for the /public to be in the url by putting

RewriteCond %{REQUEST_URI} !^/cms/public/.*$
RewriteRule ^(.*)$ /cms/public/$1 [L]

in the .htaccess file in my cms folder.

The thing is, clean urls works www.mysite.com/cms/public/ shows the Laravel starter page. But www.mysite.com/cms/ gives me a 404 not found error and www.mysite.com/cms/index.php shows the Laravel starter page.

I have set the url array element in application.php to

'url' => 'http://www.mysite.com/cms/',

and the index element to

'index' => '',

Has anyone come across this issue?

To use laravel on shared hosting, I would recommend to try this .

By the way, in your .htaccess, you are just redirecting to all non-exist request query to index.php in public directory. Because of the fact that, you should access with url.com/public.

Perhaps if you were to upload the contents of your public folder into /cms , and the other folders into /cms_system , you could change the paths.php file to reflect this?

So, you'd have this:

/cms
    (contents of the public folder, with .htaccess)
/cms_system
    /application
    /bundles
    /laravel
    /storage
    (etc)

Your paths would then look like this:

$paths['sys'] = 'system';
$paths['bundle'] = 'bundles';
$paths['app'] = 'application';
$paths['storage'] = 'storage';
$paths['public'] = '../cms';

I haven't tested this yet, but it should work. Please let me know if there are any problems with it, and will see what can be changed accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM