我正在研究一个用Symfony制作的项目,我有点问题,让我解释一下!
我的后台办公室位于此网址:https://domain.tld/platform
我的网站可以访问,但我有这个错误:
Oops! An Error Occurred
The server returned a "404 Not Found".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
我不知道为什么我会收到此消息,也许Symfony尝试从https://domain.tld/获取文件而不是https://domain.tld/platform
那我怎么能对我的htaccess说使用整个网址,https://domain.tld/platform而不仅仅是https://domain.tld?
在这里,我的.HTACCESS
我的网络服务器是Apache。
# Use the front controller as index file. It serves as fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# startpage (path "/") because otherwise Apache will apply the rewritting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/app.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
# endless redirect loop (request -> rewrite to front controller ->
# redirect -> request -> ...).
# So in case you get a "too many redirects" error or you always get redirected
# to the startpage because your Apache does not expose the REDIRECT_STATUS
# environment variable, you have 2 choices:
# - disable this feature by commenting the following 2 lines or
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
# The following rewrites all other queries to the front controller. The
# condition ensures that if you are using Apache aliases to do mass virtual
# hosting, the base path will be prepended to allow proper resolution of the
# app.php file; it will work in non-aliased environments as well, providing
# a safe, one-size fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the startpage to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
Apache配置
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
Require all denied
AllowOverride All
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
网站apache配置
<VirtualHost *:5009>
ServerName subdomain.domain.tld
ServerAlias www.subdomain.domain.tld
DocumentRoot /var/www/html/web
<Directory /var/www/html/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
Dockerfile
FROM eboraas/apache-php:latest
COPY ./ /var/www/html
COPY ./extra/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY ./extra/apache2.conf /etc/apache2/apache2.conf
COPY ./extra/ports.conf /etc/apache2/ports.conf
RUN apt-get update
RUN apt-get install curl -y
RUN curl -s https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN apt-get install php5-gd -y
RUN apt-get install nano -y
RUN apt-get install git-core -y
RUN cd /var/www/html && chown -R www-data:www-data .
RUN rm -rf /var/www/html/app/cache/prod
RUN rm -rf /var/www/html/app/cache/dev
RUN service apache2 restart
RUN a2enmod rewrite
RUN service apache2 reload; exit 0
EXPOSE 5009
Symfony错误:
request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException: "No matching accepted Response format could be determined" at /var/www/html/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/FormatListener.php line 63 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotAcceptableHttpException: No matching accepted Response format could be determined at /var/www/html/vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/FormatListener.php:63)"} []
"} [] eption: at /var/www/html/app/cache/prod/appProdUrlMatcher.php:823
非常感谢你的帮助: - )