Tomcat 不使用 httpd.conf,它是一个 apache 文件。各个 webapp 的位置保存在它们各自的 web.xml 文件中,但所有配置的位置都在 ../tomcat8/conf/server.xml 和 web.xml 中
尝试 WAMP 或 Apache2 而不是 Tomcat
您需要指示 .htaccess 文件在每次点击时加载 index.html。
喜欢
DirectoryIndex index.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|png|gif|flv|mpeg|mpg|mp4)$
RewriteRule ^.*$ bootstrap.html [NC,L]
您将在httpd.conf 文件中的LoadModule rewrite_module modules/mod_rewrite.so 中找到此行,该文件将位于conf 文件夹下。您需要从中删除哈希(#),然后重新启动 apache 服务。
如果你想在 Tomcat 中进行设置,那么我在示例项目中所做的就是在 webapps\ROOT\WEB-INF\web.xml 文件中添加以下代码
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/test/index.html</location>
</error-page>
</web-app>
这里/test/index.htmltest是我的项目名称,你可以改成你的,但尽量使用项目web.xml来避免其他项目重定向。在这种情况下,您可以直接在路径中添加/index.html