Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
没有hashbang URL的Laravel和AngularJS SEO_Angularjs_.htaccess_Laravel 4_Seo_Single Page Application - Fatal编程技术网

没有hashbang URL的Laravel和AngularJS SEO

没有hashbang URL的Laravel和AngularJS SEO,angularjs,.htaccess,laravel-4,seo,single-page-application,Angularjs,.htaccess,Laravel 4,Seo,Single Page Application,我已经为客户端开发了一个带有Laravel后端和AngularJS的网站。 我在AngularJS中启用了HTML5模式,因此URL没有散列 我使用grunt在snapshots文件夹中创建了快照。共有5个页面,每个页面都作为snapshot__page.html输出到snapshots文件夹 我在LarvelRoutes文件中使用以下代码将所有请求重定向到索引文件,以便Angular可以处理其余的请求 App::missing(function($exception) { return

我已经为客户端开发了一个带有Laravel后端和AngularJS的网站。 我在AngularJS中启用了HTML5模式,因此URL没有散列

我使用grunt在snapshots文件夹中创建了快照。共有5个页面,每个页面都作为snapshot__page.html输出到snapshots文件夹

我在LarvelRoutes文件中使用以下代码将所有请求重定向到索引文件,以便Angular可以处理其余的请求

App::missing(function($exception)
{
    return View::make('index');
});
可通过以下浏览器访问该网站:

http://www.domain.com/ 
http://www.domain.com/page1
http://www.domain.com/page2 
etc和快照正在使用中

http://www.domain.com/snapshots/snapshot__.html
http://www.domain.com/snapshots/snapshot__page1.html
http://www.domain.com/snapshots/snapshot__page2.html
谷歌表示将包括

<meta name="fragment" content="!">
我们可以满足这样的要求

我的问题在于.htaccess文件

即使当我使用“?escape\u fragement=”访问以测试页面时,也会加载索引页面。这是Laravel捕捉404条路由并服务于索引页。 关于如何为URL之间出现的?escaped_fragment=提供快照,有很多文档。 这里讨论了一个类似的问题

但是提供的.htaccess似乎不起作用

我的.htaccess文件如下所示。我在摆弄着。htaccess

<IfModule mod_rewrite.c>

 ############################################
 ## enable rewrites

Options +FollowSymLinks
RewriteEngine on

#Access site only with www
RewriteCond %{HTTP_HOST}       !domain\.com$
RewriteRule [domain]?(.*) http://www.domain.com/$1 [R=301,L]

#Snapshots for SEO  
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$
RewriteRule ^(.*)$ /snapshots/snapshot__$1.html [L,NC]


#Laravel Stuff
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]


</IfModule>

############################################
##启用重写
选项+FollowSymLinks
重新启动发动机
#只能通过www访问网站
重写cond%{HTTP_HOST}!域名\.com$
重写规则[域]?(*)http://www.domain.com/$1[R=301,L]
#搜索引擎优化快照
重写cond%{QUERY\u STRING}^\u转义\u片段_=$
重写规则^(.*)$/snapshots/snapshot__$1.html[L,NC]
#拉维尔材料
#重定向尾部斜杠。。。
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

根据上述规范,此行后面有一个下划线

重写cond%{QUERY\u STRING}^\u转义\u片段\u=$

<IfModule mod_rewrite.c>

 ############################################
 ## enable rewrites

Options +FollowSymLinks
RewriteEngine on

#Access site only with www
RewriteCond %{HTTP_HOST}       !domain\.com$
RewriteRule [domain]?(.*) http://www.domain.com/$1 [R=301,L]

#Snapshots for SEO  
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$
RewriteRule ^(.*)$ /snapshots/snapshot__$1.html [L,NC]


#Laravel Stuff
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]


</IfModule>