Removing hashUrl with rewriting example in angular js

Removing hashUrl with rewriting example in angular js

Today, We want to share with you Removing hashUrl with rewriting example in angular js.
In this post we will show you Removing hashUrl with rewriting example in angular js, hear for Removing hashUrl with rewriting example in angular js we will give you demo and example for implement.
In this post, we will learn about Removing hashUrl with rewriting example in angular js with an example.

READ :  Vue SEO Tutorial Guide for Beginners

I am Posting Url rewriting example with full source code in angular js with complete source code to achieve it . If you are angularjs beginner with angular 2 then you might faced some problems issues with hash(#) sign in angular.For in this POSTAngular SEO : Removing the hash and re-writing the .htaccess file.

htaccess redirect for Angular routes

The Google does have a include page url way of indexing AJAX call to the applications and your web app’s AngularJS app can be crawled based to the resolved, indexed and will appear created some data in search results check to just like any other more website.

Angular SEO : Removing the hash and re-writing the .htaccess file.

[php]
.config(function ($routeProvider, $locationProvider)
{
$routeProvider
.when(‘/’, { templateUrl: ‘views/main.html’, controller: ‘MainController’ })
.when(‘/about’, { templateUrl: ‘views/about.html’, controller: ‘AboutController’ })
.when(‘/careerlinks’, { templateUrl: ‘views/careerlinks.html’, controller: ‘CareerLinksController’ })
.otherwise({ redirectTo: ‘/’ });

READ :  Angular ng model Directive Example

//You’ll need this to remove the hash.
$locationProvider.html5Mode(true);
}
);
[/php]

Removing the hash and re-writing the .htaccess file. | Angular SEO

[php]
base href=”/”
RewriteEngine On
RewriteBase / RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
[/php]

In this post,URL REWRITING EXAMPLE IN ANGULAR JS is a complete Url form page rewriting example in angular js or more javascript frameworks, where i have used htaccess and Route provider for simple steps to make pretty url in angularjs

[php]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]

RewriteRule ^(.*) /index.html [NC,L]
[/php]

rewrite rules for apache 2 to use with angular js

[php]
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# simple solution of the if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api

READ :  isset vs empty vs is_null in PHP Example

# new rules define to otherwise forward it to index.html
RewriteRule ^.*$ – [NC,L]
RewriteRule ^app/. /app/index.html [NC,L]
[/php]

When a search engine(Like as a Google) crawler visits your app or web-applications and sees the data of simple it will add an ?_escaped_fragment_= tag to your URL in angularjs.

Full Source code of the Url rewriting example in angular js

[php]

Url rewriting example in angular js – SEO Friendly ANGULAR APP

http://angular.min.js
http://angular-route.js

URL REWRITING EXAMPLE IN ANGULAR JS

PHP   Laravel   Services   

var MyApp = angular.module(‘MyApp’, [“ngRoute”]);
MyApp.config([‘$routeProvider’, ‘$locationProvider’, function ($routeProvider,$locationProvider,$http){
$locationProvider.hashPrefix(‘!’);
$locationProvider.html5Mode(true);
$routeProvider

.when(‘/’,
{templateUrl:’php.html’
})
.when(‘/laravel’,
{templateUrl:’laravel.html’
})
.when(‘/services’,
{templateUrl:’services.html’
})
.when(‘/not-found’,
{templateUrl:’404.html’
})

.otherwise({
redirectTo:’/not-found’
});
}]);

[/php]

We hope you get an idea about Removing hashUrl with rewriting example in angular js
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Leave a Comment