出于某种原因,当我在Vagrant VM中运行我的Symfony 2.5应用程序时,如果我在app_dev.php路由上有一个尾部斜杠,它会破坏Web调试工具栏。
我认为在.htaccess中,我没有进行任何重定向,因为我的网址是:
mysite.dev/app_dev.php/
我可以删除/,但问题(呃,烦恼)是我有一个“家”的路径,只是“/”。所以如果我有一个“home”的链接,它会转到mysite.dev/app_dev.php/而不是mysite.dev/app_dev.php
我有默认的.htaccess,我甚至尝试添加规则来删除尾部斜杠:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
# ADDED
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
问题最终是“找不到路线”GET // _ wdt / dab5bd“
[2014-08-23 13:44:19] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET //_wdt/dab5bd" (from "http://mysite.dev/app_dev.php/")" at /var/project/app/cache/dev/classes.php line 1977 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException: No route found for \"GET //_wdt/dab5bd\" (from \"http://mysite.dev/app_dev.php/\") at /var/project/app/cache/dev/classes.php:1977, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException: None of the routers in the chain matched this request\nGET /app_dev.php//_wdt/dab5bd HTTP/1.1\r\nAccept: */*\r\nAccept-Encoding: gzip,deflate,sdch\r\nAccept-Language: en-US,en;q=0.8\r\nConnection: keep-alive\r\nCookie: PHPSESSID=886nt3bqtnf5dqo6vpiq070ve4\r\nHost: mysite.dev\r\nReferer: http://mysite.dev/app_dev.php/\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36\r\nX-Php-Ob-Level: 1\r\nX-Requested-With: XMLHttpRequest\r\n\r\n at /var/project/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ChainRouter.php:202)"} []
有什么方法吗?