删除web/app.php的引用。Symfony2
所有请求都会通过与index.php类似的文件web/app.php进行,例如对主页adwords-up.com/web/app.php、input-adwords-up.com/web/app.php/login的请求。我想从链接中删除web/app.php的一部分。在configuration.htaccess中,重定向到默认的web/app.php,这样对这样的请求就是主表单-,以及页面登录- 这里有my/etc/apache2/sites/adwords-up.conf删除web/app.php的引用。Symfony2,symfony,Symfony,所有请求都会通过与index.php类似的文件web/app.php进行,例如对主页adwords-up.com/web/app.php、input-adwords-up.com/web/app.php/login的请求。我想从链接中删除web/app.php的一部分。在configuration.htaccess中,重定向到默认的web/app.php,这样对这样的请求就是主表单-,以及页面登录- 这里有my/etc/apache2/sites/adwords-up.conf <Virt
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName adwords-up
ServerAdmin webmaster@localhost
DocumentRoot /var/www/adwords-up/web
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
这可能对你有帮助
<IfModule mod_rewrite.c>
RewriteEngine On
# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the app.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
# 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(/(.*)|$) %{ENV:BASE}/$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]
</IfModule>
将此添加到.htaccess中,并确保已激活重写引擎
这也是一个常见的问题,即使在symfon2文档上也有答案。您需要设置apache虚拟主机,并设置正确的文档根目录和重写规则。 例如:
希望有帮助您是否在apache中启用了mod_rewrite?是的。exitvar_dumpin_数组'mod_rewrite',apache_get_模块;boolean True将其放在位于/web目录中的.htaccess中是的,我将其放在那里web/.htaccess。但它不起作用。
<VirtualHost *:80>
ServerName adwords-up.com
DocumentRoot <path-to-your-codebase>/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
RewriteEngine on
RewriteOptions Inherit
RewriteRule ^/app.php/(.*) http://adwords-up.com/$1
RewriteRule ^/(.*) /app.php/$1 [QSA,L]
<Directory "<path-to-your-codebase>/web">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>