chu*_*edw 2 php .htaccess mod-rewrite symfony apache2.4
我究竟做错了什么?
这是我在 /etc/apache2/sites-enabled/hello-world.conf 上的配置
<VirtualHost *:80>
ServerName hello-world
DocumentRoot "/home/carlos/dev/github/hello-world/public"
<Directory "/home/carlos/dev/github/hello-world/public">
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/project>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/project/public/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
当我尝试访问http://hello-world/index.php/lucky/number 时一切正常。
但是使用http://hello-world/lucky/number我得到一个 404 Not Found。
404 错误是由于我配置了两个 VirtualHosts。一个在/etc/apache2/sites-enabled/000-default.conf和其他在/etc/apache2/sites-enabled/hello-world.conf。我在000-default.conf 中删除了它,现在我收到“500 Internal Server Error”。我改变这一行:
<Directory "/home/carlos/dev/github/hello-world/public">
# AllowOverride None
# Order Allow,Deny
Require all granted
# Allow from All –
Run Code Online (Sandbox Code Playgroud)
...但我仍然得到了 500。
在 /var/log/apache2/project_error.log 上有这条消息:
[Thu Apr 05 19:56:25.819680 2018] [core:error] [pid 4277] [client 127.0.0.1:38800] AH00125: Request exceeded the limit of 10 subrequest nesting levels due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Run Code Online (Sandbox Code Playgroud)
好的,最后我得到了:
这是这里的配置错误:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^(.*)$ index.php [QSA,L]
FallbackResource "index.php"
</IfModule>
Run Code Online (Sandbox Code Playgroud)
我正在关注这里所说的:https : //httpd.apache.org/docs/2.4/rewrite/remapping.html
但是后来我尝试在没有这个 FallbackResource 的情况下做,回到 Symfony 文档给我的内容,如下:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
# FallbackResource "index.php"
</IfModule>
Run Code Online (Sandbox Code Playgroud)
现在它正在工作。
谢谢你们
| 归档时间: |
|
| 查看次数: |
8481 次 |
| 最近记录: |