【发布时间】:2021-04-30 23:49:48
【问题描述】:
我在 Windows 10 中使用 xampp 运行登录时调用 API 的 slimframework。
如果我键入 localhost/maps.html,则可以访问该站点,但如果我尝试单击 index.html 中的登录按钮,则不会调用登录 API。
我已经配置了httpd和httpd-vhosts,该站点可以在本地访问,但是每当我尝试点击index.html中的登录按钮时,就会出现此错误消息:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.7
这是我的目录结构:
根目录下:
-index.php
-maps.html
-index.html
-admin/
-js/
-vendor/
-.htaccess
index.html 内:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Maps</title>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/knockout/knockout-3.0.0.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<script type="text/javascript" src="js/lib/jquery.cookie.js"></script>
<link rel="icon" href="favicon.ico" />
</head>
<body>
<div id="header">
<h1 data-bind="text:site_title"></h1>
</div>
<div id="login_container">
<div id="login_view">
<div>
<input id="loginid" type="text" data-bind="value: loginid, event:{keypress:kpLoginId}" placeholder="LoginID" />
</div>
<div>
<input id="password" type="password" data-bind="value: password, event:{keypress:kpPassword}" placeholder="Password" />
</div>
<div>
<button id="login" data-bind="click: login">Login</button>
</div>
</div>
</div>
<div data-bind="visible: failed">
Cannot Login
</div>
</body>
</html>
httpd.conf 内部:
DocumentRoot "C:\xampp\htdocs\myslimsite\web_src"
<Directory "C:\xampp\htdocs\myslimsite\web_src">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php index.pl index.cgi index.asp index.shtml index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
.htaccess 内部:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/api/v1/(.*)$ /index.php/$1 [QSA,L]
除了 httpd.conf 和 httpd-vhosts.conf 之外,是否需要配置任何其他设置才能使其他页面正常工作?谢谢。
【问题讨论】: