php - Symfony 2: Check name of host and redirect -
my website listens 2 domains: one.example.com , two.another-example.com.
when user visits contact page via "http://one.example.com/contact", automatically redirect user "http://two.another-example.com/contact". content of page same, url different one.
in controller in contactaction use following code check host:
/** * @route("/contact") */ public function contactaction(request $request) { if ($request->gethost() == 'one.example.com') { // redirect } ...
the redirect not work. 99% sure because of gethost()
-check, why included part of code.
does see solution?
you can use other ways in javascript
<script> var = window.location.href ; if(a =="your_first_domain_link") { window.location.href = "your_2nd_domain_link" } </script>
hope helps
Comments
Post a Comment