So, I developed a fully functional Laravel 5 application and deployed it to my client server using Apache2, PHP5 and MySQL. The application works as expected, and the URLs are correctly rewritten. Now I just need to clone my application to another server that works on exactly the same stack. The problem is that I need to put my application in a subfolder so that it can be accessed through the URLs matching the domain2.com/movedApp pattern.
In other words: The first server responds to:
domain1.com/my/routes
The second server should respond to:
domain2/movedApp/my/routes
I tried to reproduce exactly the VirtualHost directive, which runs on the first server, adding /movedApp where necessary, and adding RewriteBase to the .htaccess file in the new public folder, but to no avail.
I noticed that routes follow correctly from URLs, for example:
domain2.com/movedApp/public/index.php/my/routes
However, I get an 404 error about assets in the Apache2 log.
I hereby inform you of my .htaccess file located in the public folder of my working Laravel application.
.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>
I also report the configuration file used by the web server to serve my application
default.conf
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/galmaster/public <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/galmaster/public> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>