我知道這已被問了很多次,但有些奇怪的事情正在發生在我身上。 Apache的DocumentRoot的指向的symfony /網絡/這是我的web /目錄內的.htaccess:Symfony:htaccess隱藏app.php或app_dev.php
DirectoryIndex app_dev.php
#DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ app_dev.php [QSA,L]
#RewriteRule ^(.*)$ app.php [QSA,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule .? %{ENV:BASE}app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
好了,事情是www.example.com/route1/
工作和www.example.com/route2/
拋出一個錯誤:
Oops! An Error Occurred The server returned a "404 Not Found". Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
雖然www.example.com/app_dev.php/route2/
工作正常(還www.example.com/app_dev.php/route1/
)
幫助?
更新。緩存督促明確拋出這個錯誤(我以前從來沒有嘗試過,我正在開發):
[Doctrine\Common\Proxy\Exception\UnexpectedValueException] The type hint of parameter "userRoles" in method "addRole" in class "MyProject\PanelBundle\Entity\User" is invalid.
[ReflectionException] Class Maycol\BlogBundle\Entity\Role does not exist
由於某種原因'RewriteRule^app \ .php(/(.*)| $)%{CONTEXT_PREFIX }/$ 2 [R = 301,L]'只適用於'/ app.php /'個案,而不是'app.php'。我不得不復制這些行,而是添加一個'RewriteRule^app \ .php $%{CONTEXT_PREFIX}/[R = 301,L]'條目。不知道爲什麼作爲正則表達式的作品! – PeterB
你能顯示你的最終文件嗎? 我無法在生產服務器上工作(app.php) – InsaurraldeAP