apache2 中默认加载 index.html

apache2 中默认加载 index.html

我已经设置了apache2Web 服务器和 Tomcat,并mod_jk在它们之间设置模块来将静态内容委托给apache2

我已经创建/var/www/example/index.html并希望在输入时加载www.example.com/

我可以直接访问www.example.com/index.htmlwww.example.com/会加载 tomcat 默认页面。

这是我的 Apache 配置文件:

<VirtualHost *:80>
    DocumentRoot /var/www/example
    <Directory /var/www/example>
            DirectoryIndex index.html
            #Options Indexes FollowSymLinks
            #AllowOverride None
            #Require all granted
    </Directory>
    # Static files in the examples webapp are served by Apache
    # Alias /examples /opt/tomcat/webapps/example
    # All requests go to ajp13_worker by default
    JkMount /* ajp13_worker
    # Serve this files using Apache
    JkUnMount /*.html ajp13_worker
    JkUnMount /*.jpg ajp13_worker
    JkUnMount /*.gif ajp13_worker
    JkUnMount /*.png ajp13_worker
    JkUnMount /*.svg ajp13_worker
    JkUnMount /*.js ajp13_worker
    JkUnMount /*.css ajp13_worker

    ServerAdmin info@example

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

我尝试更改索引文件的权限,并用“ ”添加.htaccess文件,但没有任何效果。/var/www/exampleDirectoryIndex index.html

有什么建议么?

答案1

好的,我解决了。将配置文件更改为:

<VirtualHost *:80>
DocumentRoot /var/www/example
<Directory /var/www/example>
        DirectoryIndex index.html
        #Options Indexes FollowSymLinks
        #AllowOverride None
        #Require all granted
</Directory>
# Static files in the examples webapp are served by Apache
Alias /example /opt/tomcat/webapps/example
# All requests go to ajp13_worker by default
JkMount /* ajp13_worker
# Serve this files using Apache
JkUnMount /example/*.html ajp13_worker
JkUnMount /example/*.jpg ajp13_worker
JkUnMount /example/*.gif ajp13_worker
JkUnMount /example/*.png ajp13_worker
JkUnMount /example/*.svg ajp13_worker
JkUnMount /example/*.js ajp13_worker
JkUnMount /example/*.css ajp13_worker

ServerAdmin info@example

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

相关内容