php / symfony2从URL隐藏app.php
发布时间:2020-12-13 16:24:34 所属栏目:PHP教程 来源:网络整理
导读:请考虑以下URL: http://www.myurl.fr/accueil. 它不会起作用.但是http://www.myrurl.fr/app.php/accueil确实有效. 我摆脱了.htaccess文件,因为我想使用vhost文件并依赖Apache路由.我的vhost文件如下: VirtualHost my.ip.addressServerName myurl.frServerA
请考虑以下URL:
http://www.myurl.fr/accueil.
它不会起作用.但是http://www.myrurl.fr/app.php/accueil确实有效. 我摆脱了.htaccess文件,因为我想使用vhost文件并依赖Apache路由.我的vhost文件如下: <VirtualHost my.ip.address> ServerName myurl.fr ServerAlias www.myurl.fr DocumentRoot /var/www/mysite/web DirectoryIndex app.php <Directory "/var/www/mysite/web"> AllowOverride All Allow from All </Directory> <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^app.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L] RewriteRule .? - [L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$app.php [QSA,L] RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteRule .? %{ENV:BASE}app.php [L] </IfModule> </VirtualHost> 我已经清除了Apache缓存并重启了很多次. urlrewrite mod已启用.我只是不知道还有什么要检查.知道我错过了什么吗? 编辑
将您的规则与symfony-standard
.htaccess进行比较,我发现您在“传递所有规则”之前错过了文件检查.尝试
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::2$ RewriteRule ^(.*) - [E=BASE:%1] 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] # Rewrite all other queries to the front controller. RewriteRule .? %{ENV:BASE}/app.php [L] </IfModule> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |