Laravel 5 - Copied Entire Project to Sub-Folder | 404 Error Good day Everyone,
I have made a copy of my 100% working Laravel web app on another domain/host.
On the new domain, my Laravel projects sit in a subfolder for example: www.domain.com/laravel
When I browse to www.domain.com/laravel my home page loads perfectly without any errors.
But as soon as I select any sub route I receive a 404 error.
For example www.domain.com/laravel/register would not work.
Cleared all the cache files as well.
Laravel 5.
Any guidelines on what to check and change when you make a precise copy of your website and paste it into a sub-folder on another domain (and host).
Thanks in advance :)
Its not a recommended solution. You would need to mess with .htaccess as well as any urls that have been coded to be relative to the root '/'
Mmmm that is a pity because I do not have many alternatives. Someone wants to use my solution on their existing domain.
maybe , you can change the port , like domain.com:8080 to run laravel , 80 to run original
consider a subdomain
site2.customerdomain.com
then you can still have everything relative to root.
Awesome @snapey never thought about that one! So then I can have my file structure exactly is my working domain?
yes. the site is not really aware it runs in a subdomain
Okay cool - I did just that.
Cleared all cache: route, view, cache
but still I can access my root route. Home page loads perfectly.
But when I browse to any child route I get Document not found.
Please any suggestion much appreciated :)
If have even setup a basic test Route::get() bit won't work.
Route::get("/test", function() {
dd("Test");
});
Also cleared browser history.
When change home route it works but no other child routes will work.
My .env also updated to correct domain (sub).
Okay for future reference - got it solved.
.htaccess file was the damn issue.
When I put /index.php/user then sub routes working.
My .htaccess that solved the issue:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
<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>
#php_flag register_argc_argv 1
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Please sign in or create an account to participate in this conversation.