Ad
.htaccess Redirection For SEO Configuration
I have an angularJs based portfolio, Google crawler offer a URI tool for similar platforms. replaces the #!
by ?_escaped_fragment_=
which you can use server redirection to changed the directory to serve static files.
I don't use #!
so the ?_escaped_fragment_=
will be inserted at the end. What I like to do is to make this pattern:
www.mywebsite.com/?_escaped_fragment_=
www.mywebsite.com/page/?_escaped_fragment_=
www.mywebsite.com/page/5?_escaped_fragment_=
Redirects to
www.mywebsite.com/snapshot
www.mywebsite.com/snapshot/page/
www.mywebsite.com/snapshot/page/5
This is the .htaccess file that I used:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$
RewriteRule ^$ /snapshot/
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html
The problem is that It only works for the base URL (index.html). Is there a thing that I am missing? Thank you.
Ad
Answer
You have to use the escaped fragment like this:
http://yourangularwebsite.com/?_escaped_fragment_=/page/5
Then redirect it in your .htaccess:
RewriteCond %{QUERY_STRING} _escaped_fragment_=/([^&]*)
RewriteRule ^$ /snapshot/%1 [R,L]
This should redirect you to http://yourangularwebsite.com/snapshot/page/5?_escaped_fragment_=/page/5
Ad
source: stackoverflow.com
Related Questions
- → Make a Laravel collection into angular array (octobercms)
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → Angularjs not working inside laravel form
- → Analysis of Flux implementations
- → how to write react component to construct HTML DOM
- → angular ng-repeat and images in a row
- → Conditional BG Color on AngularJS
- → Should I 'use strict' for every single javascript function I write?
- → getting the correct record in Angular with a json feed and passed data
- → "Undefined is not a function" at .toBe fucntion
- → angularjs data binding issue
- → Angular / JavaScript auto hydrate an instance
- → Convert generic text string in json object into valid url using Angular
Ad