MVC Routing / HostHeader does not work when I use RequireHttps - model-view-controller

I'm currently experiencing an issue whereby my MVC site is not responding correctly using IIS 6.
I've setup a url as http://mysite.co.uk which automatically redirects to the correct MVC home page. As the site contains sensitive information I have added the [RequireHttps] attribute to each controller class to automatically redirect the browser to an https url of https://mysite.co.uk which works correctly.
When I access the site as http://www.mysite.co.uk the site correctly redirects to https://www.mysite.co.uk/Default.aspx but it then responds with
Bad Request (Invalid Hostname)
It looks like any time I use www. as part of the url it fails to respond but I have a hostheader setup as www.mysite.co.uk under the IIS website. Is there anything in particular I need to do to make MVC understand the www. part of the url in terms of routing?
Thanks,
Brian.

IIS 6 doesn't add ssl host headers as you think it would. see my article at:
http://completedevelopment.blogspot.com/2009/06/multiple-host-headers-ssl-and-wcf.html

Related

Angular UI-Router (1.x) Change Host Url

I have a requirement from a client to change the web site Url to a subdomain when they enter the checkout section of the site we are developing for them. For example from www.mysite.com to checkout.mysite.com. We are using UI-Router in HTML5 mode and would like to have the router change the Url to the subdomain instead of going to www.mysite.com/checkout. Does anyone know a way that this can be accomplished? I've also tried using pushState but without success. All of the subdomain suggestions I've tried have not worked. Honestly even if I just put a "fake" url that would work fine too. Changing the Url is more of a visual thing instead of actually redirecting to a subdomain.
After much review I found that this cannot be done because it is a security issue; even switching to a subdomain (which is what I was trying to do) is not allowed.

Magento site redirects to home page when ssl is enabled

I am using magento 1.8.1.0 and i have enabled SSL. SSL is purcahsed from Godady and is installed and configured at the server.
I have also set the Base URL in secure section to https://..... . Now when i enable it for front end, and then when i try to go to customer login page (which is served by https), i am always redirected to home page.
I have applied a few fixes, but no one worked.
The fix described on the below link starts a redirect loop and the site never loads.
Magento HTTPS on all website: urls redirect to homepage
Also i have read the following:
http://www.aschroder.com/2012/07/magento-ssl-offloading-with-amazon-elb/
https://magento.stackexchange.com/questions/38250/ssl-issues-with-magento-behind-load-balancer-302-loop
http://blog.ideaday.de/max/2012/12/magento-https-redirect-loop-ssl-offloading-proxies-pound-nginx/
https://www.sonassi.com/knowledge-base/magento-kb/magento-https-redirect-loop/
http://magentocoder.jigneshpatel.co.in/magento-redirection-loop-problem-after-installing-ssl/
And no fix is working for me.
Now i am offering a 50 points bounty for the correct answer.
Can someone give me some idea how to fix this issue?
Thank you
I saw this problem while on a login form submitted via ajax, the login form was loaded as part of a http page as opposed to https, which is not good, and then the login form data submitted by ajax to a https controller url. on success some javascript would try to load a https landing page into the main window.
The problem was magento would redirect the landing page which is what you're experiencing.
To solve hte issues, we loaded the login form by https and dynamically put it into the dom. We used the form action to a https link, and a form submit rather than an ajax post. Then the magento controller would use a redirect in the response to the landing page or an error page.
Go to Your system->confi->web->Session Validation Settings
Validate HTTP_X_FORWARDED_FOR and Validate HTTP_USER_AGENT
this two fields are enable so only disable it ! :)

Spring controller redirects to wrong url

I have a little problem with my spring web application. I run my application on VPS with Tomcat. VPS comes with url 24524.vps.com for example. I parked my domain, to redirect domain.com for example to my vps server hostname. And the problem comes here:
All my controllers and pages work with domain.com url. But when I use return "redirect:main"; in my controller, I get redirected to url 24524.vps.com/main and not to domain.com/main.
How to force redirecting to url domain.com/main?
Im not sure if this is the problem but when i use redirect i put a slash in front of the link.
return "redirect:/main";
the problem wanst in spring.... VPS host was 24524.vps.com so thats why spring redirected to 24524.vps.com... I forced my VPS to use domain.com as host and all problems gone.

Cake PHP redirection

CakePHP redirection of url like *.php
My site is integrated with more than 20 other sites.
They have a url to access my site
Now i rewrite my code in CakePHP .
So i want to redirect the old urls to the corresponding cakePHP page
You may use the routes configuration to add some paths that resolve your current urls sending them to the appropriate action:
http://book.cakephp.org/2.0/en/development/routing.html#routes-configuration
However, I think you should manage that situation directly in your web server whatever it be (apache, nginx, etc).

IIS 7.5 URL Rewrite Different Domains pointed to a single site

I have a single site at www.domain1.com. It's a PHP site being hosted on a Windows 2008/IIS 7.5 box. I need to set up www.domain2.com so that users are redirected to www.domain1.com/subfolder. To the user, they still see www.domain2.com in the address bar but are looking at the www.domain1.com/subfolder.
Any help on how to achieve this would be greatly appreciated!
You need to use IIS Application Request Routing and Url Rewrite modules. This walkthrough describes almost exactly what you are trying to achieve.

Resources