19 Dec
Remove hash from AngularJs url
Rewrite your AngularJs app url from http://domain.com/#/path/ to http://domain.com/path/
There are few things to set up for remove hash from AngularJs url. So your link in the browser will look like http://domain.com/path/ and these are your base href + angularjs config + .htaccess url rewrite.
1) Base href
Set the base href in HTML file.
<html> <head> <base href="/"> </head> </html>
2) Angularjs
Add html5Mode inside your angularjs config file.
app.config(function ($routeProvider,$locationProvider) { $routeProvider .when('/', { templateUrl: 'home-page.html', controller : 'appController' }); $locationProvider.html5Mode(true); });
3) .htaccess url rewrite
Put this inside your .htaccess file.
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /#/$1 [L]
Latest posts by Sanju (see all)
- Top 10 Features in Angular 18 You Need to Know - June 25, 2024
- Specialities of Kerala’s agricultural and religious festival Vishu - November 25, 2022
- Why Kerala is known as God’s own country – Part 2 - June 20, 2019