How to remove hashbang #! from url ?

How to remove hashbang #! from url ?

Asked on November 12, 2018 in vue.js.
Add Comment


  • 2 Answer(s)

    Set mode to ‘history’

    const router = new VueRouter({
      mode: 'history'
    })
    

    Your server must configured to handle these links, through,  https://router.vuejs.org/guide/essentials/history-mode.html

    Answered on November 12, 2018.
    Add Comment

    Another approach to remove hashbang

    window.router = new VueRouter({
       hashbang: false,
       //abstract: true,
      history: true,
        mode: 'html5',
      linkActiveClass: 'active',
      transitionOnLoad: true,
      root: '/'
    });
    

    Apache server should be properly configured and rewrite the url

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.html$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.html [L]
    </IfModule>
    
    Answered on November 12, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.