我是第一次在Apache上部署。
这是我的虚拟主机配置:
<VirtualHost *:80>
DocumentRoot /var/www/myproject.com/web/my-project/Client/app/
ServerName myproject.com
ServerAlias www.myproject.com
ErrorLog /var/log/ispconfig/httpd/myproject.com/error.log
Alias /error/ "/var/www/myproject.com/web/error/"
Alias /api/ "/var/www/myproject.com/web/my-project/Server/"
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html
</VirtualHost>
这是我的.htaccess文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /api
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
我的HTML和Javascript正确提供。但API调用正在响应404,说'在此服务器上找不到请求的URL。'
当请求'my-project / api / countries'时,为什么没有从我的route.php找到'country'路线?
修改: 我刚检查了我的错误日志,它多次显示'AH01630:服务器配置拒绝客户端'。
答案 0 :(得分:0)
您的一条重写规则需要更正。请参阅以下正确的指令:
RewriteEngine On
RewriteBase /api
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1 [L,R=301]