Apache 更改所有控制器的symfony中的baseURL
因此,我将应用程序托管在apache服务器上Apache 更改所有控制器的symfony中的baseURL,apache,symfony,routing,Apache,Symfony,Routing,因此,我将应用程序托管在apache服务器上/~test/下的一个子目录中 我尝试在路由中添加前缀,但没有任何结果 我希望所有控制器的所有路由都以/~test/开始,而无需手动将其添加到每个路由。现在,当路由转到/时,它超出了我的/~test/目录 例如: /** * @Route("/login", name="app_login") */ public function login(AuthenticationUtils $authenticationUtil
/~test/
下的一个子目录中
我尝试在路由中添加前缀,但没有任何结果
我希望所有控制器的所有路由都以/~test/
开始,而无需手动将其添加到每个路由。现在,当路由转到/时,它超出了我的/~test/
目录
例如:
/**
* @Route("/login", name="app_login")
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
}
这条路线我想去/~test/login
我的.htaccess:
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
DirectoryIndex.php
选项-多视图
重新启动发动机
RewriteCond%{REQUEST_URI}:$1^(/.+)/(.*):\2$
重写规则^(.*)-[E=基:%1]
RewriteCond%{HTTP:Authorization}。
重写规则^-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
RewriteCond%{ENV:REDIRECT_STATUS}^$
重写规则^index\.php(?:/(.*)|$)%{ENV:BASE}/$1[R=301,L]
RewriteCond%{REQUEST_FILENAME}-f
重写规则^-[L]
重写规则^%{ENV:BASE}/index.php[L]
重定向匹配307^/$/index.php/
.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /public/index.php [L]
</IfModule>
重新启动发动机
重写规则^$/public/index.php[L]
看看这个
您可以在routes.yaml文件中编写类似的内容:
controllers:
resource: ../src/Controller/
type: annotation
prefix: /cool-prefix
将SetEnv BASE“/test”添加到。htaccess@mblaettermann尝试过了,这将它放在htaccess的顶部,但没有结果,这可能是因为apache设置我不知道它是否允许覆盖我无法访问根配置您的Symfony版本?也可以复制粘贴你的主文件URL@Trixsymfony 4.1我的url基本上位于企业内部网上uni.co.uk/~myusername/,您希望symfony应用程序主页位于
http://uni.co.uk/~myusername/test/
?还有什么?