简体   繁体   English

Laravel + Apache +路由配置资产?

[英]Laravel + Apache + Routes Configuration Assets?

I have the following problem trying to put my app in production related to apache2 routes and Laravel routs. 我在将我的应用投入与apache2路线和Laravel溃败相关的生产时遇到以下问题。

What I have : 我有的 :

Server1 - Domain www.example.com <--- working with other apache and website Server1-域www.example.com <---与其他Apache和网站一起使用

server2 - Domain www.example.com/myapp <--- Server for my App Production server2-域www.example.com/myapp <---我的App生产服务器

Laravel 5.5 Apache2 PHP 7.1 Laravel 5.5 Apache2 PHP 7.1

Apache confs Apache配置文件

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/html >
               AllowOverride All
     </Directory>
</VirtualHost>

.htpasswd file Options -MultiViews .htpasswd文件选项-MultiViews

RewriteEngine On

# Redirect www to non-www
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

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

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

The problem is when I type on the browser www.example.com/myapp I access server2 but my css assets call server1 like www.example.com/css/app.css instead of calling www.example.com/myapp/app.css. 问题是,当我在浏览器www.example.com/myapp上键入时,我访问server2,但我的CSS资产调用的是server1,如www.example.com/css/app.css,而不是调用www.example.com/myapp/app。 css。

How can I solve this issue ? 我该如何解决这个问题?

Thanks in advance for the support. 预先感谢您的支持。

Best 最好

If I understand correctly, you can make use of the base element in the head section of your html/blade file. 如果我理解正确,则可以使用html / blade文件头部的base元素。 Like 喜欢

<head>
    <base href="www.example.com/myapp">
    <link rel="stylesheet" href="css/app.css">
</head>

This will resolve the link to www.example.com/myapp/css/app.css 这将解决指向www.example.com/myapp/css/app.css的链接

Read more at https://www.w3schools.com/tags/tag_base.asp https://www.w3schools.com/tags/tag_base.asp上了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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