Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove # from URL in Aurelia

Tags:

aurelia

Can anybody please explain in step by step manner, how can we remove # from URL in Aurelia

like image 935
Pratik Gajjar Avatar asked Apr 15 '16 14:04

Pratik Gajjar


People also ask

How do I remove a tick?

Use clean, fine-tipped tweezers to grasp the tick as close to the skin's surface as possible. Pull upward with steady, even pressure. Don't twist or jerk the tick; this can cause the mouth-parts to break off and remain in the skin. If this happens, remove the mouth-parts with tweezers.

How do you get a tick to back out?

The easiest and simplest way to make a tick back out is to detach it manually with tweezers. Grasp the tick with the tweezers as close to the skin's surface as possible. Pull the tick upward with steady, even pressure without twisting the tick.

How do you remove a tick with Vaseline?

Do not twist the tick when pulling it out. Do not try to kill, smother, or lubricate the tick with oil, alcohol, petroleum jelly, or similar material while the tick is still embedded in the skin.


2 Answers

The feature you are looking for is called PushState. You can find more info in Cheat Sheet section of Aurelia Hub. Just scroll down to Routing / Configuring PushState.

  1. Add a base tag to the head of your HTML document. I don't think this is a required step, since my apps are working without it.

  2. If you are using JSPM, configure baseURL (in config.js file).

  3. Enable PushState in router config:

    export class App {
        configureRouter(config) {
            config.title = 'Aurelia';
            config.options.pushState = true; // <-- this line
            config.map([
                //... 
            ]);
        }
    }
  1. Configure server to support PushState. Basically, this means that your server should redirect all unknown routes/URLs to the home URL (the address of your Aurelia app - index.html, /home/index...).

    This step depends on the server-side technology you are using. I.e. for ASP.NET MVC, this is how you would define your route config:

    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            // url: "{*pathinfo}" - this redirects all server side calls
            // to Home/Index (default route)
            // with this single change, HTML5 push state is enabled
            routes.MapRoute(
                name: "Default",
                url: "{*pathinfo}",
                defaults: new { 
                    controller = "Home", 
                    action = "Index", 
                    id = UrlParameter.Optional 
                }
            );
        }
    }

Edit: Dwayne Charrington has a nice article about PushState on his Discover Aurelia site, where he explains how to configure PushState on various server-side frameworks, like Apache, Nginx, .NET Core and Node.js Express.

like image 97
Miroslav Popovic Avatar answered Oct 16 '22 10:10

Miroslav Popovic


If you looking for a quick way to make it work do the following:

  1. in router config in src/app.ts :

    config.options.pushState = true;

  2. in index.html of root directory add the following :

    <base href="/">

like image 3
Delavega Avatar answered Oct 16 '22 09:10

Delavega