Remove # from url in Angular JS and Laravel 5

To remove # from Angular JS application built with Laravel , add following line in your config.

Add this in your head tag

Now it will work fine till you do not refresh the page. If you refresh your page at this point, you will see page not found error, it is because now browser sends request to server and server doesn’t have the route.

To do this we will add this route at the end of routes.php



  • Gurpal Singh

    Not working every time redirected to home page when i click on any link or button

    • Devendra Verma

      Hi @disqus_GLKctdbk2t:disqus do you have a single page angular application or is it with any server side framework like laravel, codeigniter or expres js etc.

      • Gurpal Singh

        yes i am working on framework like laravel 5

        • Devendra Verma

          Can you please post your route.php here

          • Gurpal Singh

            Now its working fine. There are interceptor problem that i had used. So it is redirected to home page. Many-2 thanks Devendra

          • Devendra Verma

            Glad to know that 🙂

  • Varun

    can you please post the routes.php code for code igniter

  • Amr AbdelRahman

    in the project folder create .htaccess file an then write
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^$ [NC]
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.html [L]

    follow this link: