简体   繁体   中英

Symfony Redirect

guys I'm new with Symfony and I have the follow question to see if this is possible.

Righ now I have an app that runs on Symfony that is located in www.domain.com/app and I want to if a user visits the URL redirect to another website (since a lot of users tries to brute force the login dashboard) but if I put the Symfony app login URL that is www.domain.com/app/dashboard/login the login dashboard appears.

I have to try to do something with .htaccess but with not luck.

Thanks

maybe something like

RewriteRule ^app$ "http://otherwebsite.example.com/$1"  [R,L]

in your .htaccess ? The complete login URL will still work because this Rule only catches URLS ending with app

Actually your question is not so Symfony specific. It is more about Rewrite Rules. Also, why not just answer with an error 404 if somebody accesses /app, (here with optional trailing slash) ?

RewriteRule ^app(\/?)$ - [L,R=404]

重定向任何请求,您都可以使用return $this->redirect('http://stackoverflow.com');

You have a lot of soulion this one :

public function indexAction()
{
   return $this->redirect('http://symfony.com/doc');
}

don't forget to check the documentation:

http://symfony.com/doc/2.8/controller.html#redirecting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM