【问题标题】:Html5 mode with Hashbang Route for direct url on pages带有 Hashbang Route 的 Html5 模式,用于页面上的直接 url
【发布时间】:2015-10-20 02:48:00
【问题描述】:

我在我的投资组合中使用 AngularJS。我想让它兼容并完全由 Googlebot 抓取。所以,我尝试在配置中设置html5模式。

“#”现在消失了,但我无法直接访问页面。服务器向我发送 404。

我正在使用 Apache 服务器。我通常将我的服务器配置为使用 .htaccess 在索引上路由请求。

我的作品集已经在服务器上My portfolio

你可以在我的github上看到代码Here

【问题讨论】:

    标签: angularjs html apache url seo


    【解决方案1】:

    您需要配置您的服务器,以便它将所有路由请求重定向到 angular...

    read here 如何:配置您的服务器以使用 html5Mode

    在阿帕奇

    <VirtualHost *:80>
        ServerName my-app
    
        DocumentRoot /path/to/app
    
        <Directory /path/to/app>
            RewriteEngine on
    
            # Don't rewrite files or directories
            RewriteCond %{REQUEST_FILENAME} -f [OR]
            RewriteCond %{REQUEST_FILENAME} -d
            RewriteRule ^ - [L]
    
            # Rewrite everything else to index.html to allow html5 state links
            RewriteRule ^ index.html [L]
        </Directory>
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2012-07-27
      • 2012-07-17
      • 1970-01-01
      • 2017-07-30
      • 2013-05-16
      • 2016-08-14
      • 2014-08-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多