0

I have an application with routing on php. Here is the simple example:

$req=$_SERVER['REQUEST_URI'];
if(strpos($req, '/items/') === 0){
    include __DIR__.'/../views/items/index.php';
} else{
    include __DIR__.'/../views/login/index.php';
}

on each page (items and login) angularjs routing is used. And all works perfectly except IE9 and below. After page load, angular updates url and reloads the page for routing with hash navigation. And I get the following problem in IE:

  1. enter url = /items/23
  2. server returns page items/index.php
  3. AngularJS changes url to /#!/items/23
  4. Server cannot read data after hash symbol, and think that url is / so it returns page login/index.php

As result I cannot open the items page in IE. How can I fix problem? I used to make redirect on the event $routeChangeSuccess in IE, to add query parameters to read it on the server side, but the new version of angular routing put the query parameters after hash and they are cannot be read on the server side.

Angular location provider is $locationProvider.html5Mode(true).hashPrefix('!');

1 Answer 1

1

Have you found a solution yet?

I am thinking of modifying the angularjs code to store the path in a cookie that could be then retrieved from php when angular refresh the page to change the URL to be hashbang (ie8 in html5mode)

Issue opened here https://github.com/angular/angular.js/issues/6195

Pull request here https://github.com/angular/angular.js/pull/6303

Sign up to request clarification or add additional context in comments.

2 Comments

Yes it is kind of solution, but I don't really want to update angularjs code, because if I would like to update angular version these changes could be lost. So I use session to store url before routing in IE8 in php. It's ugly solution but it works pretty well in my case
Nice, add link to the answer and I will vote +1 for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.