因此,我开发了一个功能齐全的Laravel 5应用程序,并将其部署到我的客户服务器上,运行Apache2,PHP5和MySQL。该应用程序按预期工作,并且URL被正确地重写。 我现在需要简单地将我的应用程序克隆到另一台服务器,该服务器运行的是完全相同的堆栈。问题是我需要将我的应用放在子文件夹中,以便可以通过匹配模式domain2.com/movedApp
的URL访问它。在服务器子文件夹中移动Laravel 5应用程序
换句话说: 首先服务器响应:
domain1.com/my/routes
二服务器需要回应:
domain2/movedApp/my/routes
我想完全照搬了虚拟主机指令,它的第一台服务器上的工作,在需要的地方添加/movedApp
并将RewriteBase
添加到.htaccess
文件夹中的新文件夹public
,但无济于事。
我已经注意到,路由正确地从像URL如下:
domain2.com/movedApp/public/index.php/my/routes
不过我得到的Apache2的日志资产404错误。
我在此报告我的.htaccess
文件位于我工作的Laravel应用程序的public
文件夹中。
的.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>
我还报告所使用的Web服务器为我的应用程序
default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
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>
你有什么成功吗? – urfusion
是的,我其实有。一有空余时间,我会尽快公布细节。我设法用两个'.htaccess'文件来解决这个问题。 – ibanjo
我发布了一个解答我自己的问题的答案。也许我的解决方案也适合你。 – ibanjo