简体   繁体   English

PHP路由的Apache虚拟主机配置

[英]Apache Virtual Host configuration for PHP routes

I am deploying on an Apache for the first time. 我是第一次在Apache上进行部署。

Here is my Virtual Host configuration: 这是我的虚拟主机配置:

<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>

Here is my .htaccess file: 这是我的.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>

My HTML and Javascript are served properly. 我的HTML和Javascript已正确投放。 But the API calls are responding with 404, saying ' The requested URL was not found on this server. 但是API调用以404响应,并说' 在此服务器上找不到请求的URL。 ' '

Why is it not finding 'countries' route from my route.php when 'my-project/api/countries' is requested? 为什么在请求“ my-project / api / countries”时无法从route.php中找到“国家”路由?

EDIT : I just checked my error log and it is showing 'AH01630: client denied by server configuration' several times. 编辑 :我刚刚检查了我的错误日志,它多次显示“ AH01630:服务器配置拒绝了客户端”。

One of your rewrite rules needs correction. 您的重写规则之一需要更正。 See correct directives below: 请参阅下面的正确指令:

 RewriteEngine On
 RewriteBase /api
 # Redirect Trailing Slashes If Not A Folder...
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ $1 [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM