使用别名的apache中的SPA

时间:2017-05-10 21:37:02

标签: apache reactjs single-page-application

我尝试设置apache,因此它将wordpress的一个实例作为主站点,并在子路径中使用React-Redux创建一个SPA。我使用过this configuration但它只在SPA是根应用程序时才有效。

这是我的apache配置:

<VirtualHost *:80>
        ServerAdmin <MY SERVER AMDIN>
        ServerName <MY SERVER NAME>
        ServerAlias <MY SERVER ALIAS>

        Alias /my-sub-site "/var/www/my-sub-app-folder"
        <Directory>
            RewriteEngine on
            # Don't rewrite files or directories
            RewriteCond %{REQUEST_FILENAME} -f [OR]
            RewriteCond %{REQUEST_FILENAME} -d
            RewriteRule ^ - [L]
            # Rewrite everything else to index.html to allow html5 state links
            RewriteRule ^ index.html [L]
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

有没有人成功完成这项工作?当我在http://myserver/my-sub-site访问应用程序无法加载的URL时,在控制台中我看到资源(.js,.css,.jpeg等)未被解析为子路径/ my-子站点,但到根。

即。而不是请求http://myserver/my-sub-site/vendor.js它尝试请求http://myserver/vendor.js

任何帮助将不胜感激。

0 个答案:

没有答案