Hi,
I am trying to adapt my web application to be able to use #! in the url so that I can use that to direct web crawlers to html snapshots of my dynamic pages.
What I want to do is add #! as a prefix to a group of routes, but Laravel does not seem to recognize this.
I want the url to look like: http://domain.com/#!/series/1/1
Example:
Route::group(['prefix' => '#!'], function () {
Route::get('series', 'SeriesController@show');
.
.
.
}
Has anyone tried this before? Gotten it to work this way? Or another way?
Second question: Would it be better for the URL to look like this? http://domain.com/series/#!/1/1
Love to get your feedback!
EDIT: A prefix of just '!' works just fine, but when I add the '#' it treats the rest of the url as a comment it seems. I have tried url encoding the # to &23 in the prefix array to no avail either.
This works:
Route::group(['prefix' => '!'], function () {
Thanks, Michael
GameWisp
The part of a URL starting with # is called the fragment
, the fragment
is not sent to the server when a request is made by your browser, it is only available clientside. If you visit example.com/page#fragment
the server will only see example.com/page
as the request.
this should be your only route
Route::get('series', 'SeriesController@show');
inside method show
you should check it's an ajax call or not and return json or html
also check if google is trying to get it with _escaped_fragment_
source: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
Thanks guys for the insight. I was definitely thinking about it all wrong, so this really helped clarify things.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community