prerender htaccess for subirectory url
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了prerender htaccess for subirectory url相关的知识,希望对你有一定的参考价值。
这是我的htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
RequestHeader set X-Prerender-Token "**************"
<IfModule mod_rewrite.c>
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
# Proxy the request
RewriteRule ^(.*)$ http://service.prerender.io/http://%{HTTP_HOST}$1 [P,L]
RewriteRule ^ /index.html
</IfModule>
</IfModule>
我在Angularjs做过这些 -
<head>
<meta name="fragment" content="!">
</head>
$locationProvider.html5Mode(true);
我的网址看起来像 -
https://www.{Hostname}/{folder-name}/ (BaseURl)
当我在下面的网址上点火时,它会将我重定向到404
https://www.{Hostname}/{folder-name}/category/category-name
任何人都可以帮我摆脱这个htaccess问题吗?
答案
您需要确保Prerender配置在.htaccess的此部分之前运行:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
您的.htaccess可能如下所示:
RewriteEngine On
RequestHeader set X-Prerender-Token "**************"
<IfModule mod_rewrite.c>
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
# Only proxy the request to Prerender if it's a request for HTML
RewriteRule ^(?!.*?(.js|.css|.xml|.less|.png|.jpg|.jpeg|.gif|.pdf|.doc|.txt|.ico|.rss|.zip|.mp3|.rar|.exe|.wmv|.doc|.avi|.ppt|.mpg|.mpeg|.tif|.wav|.mov|.psd|.ai|.xls|.mp4|.m4a|.swf|.dat|.dmg|.iso|.flv|.m4v|.torrent|.ttf|.woff|.svg))(.*) http://service.prerender.io/https://%{HTTP_HOST}.com/$2 [P,L]
</IfModule>
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
如果这不能解决问题,请随时发送电子邮件至support@prerender.io,并提供更多信息,以便我们提供帮助!
以上是关于prerender htaccess for subirectory url的主要内容,如果未能解决你的问题,请参考以下文章
apache_conf Apache的官方prerender.io .htaccess。
xml htaccess for web.config IIS(Windows Server)for Wordpress