我们必须在放置第二台服务器的同时将站点放置大约半小时。使用.htaccess,我如何将任何请求重定向到domain.com
到domain.com/holding_page.php
?htaccess:如何将所有页面重定向到一个保留页面
4
A
回答
5
-3
这工作得更好......
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/holding_page.php$
RewriteRule $ /holding_page.php [R=307,L]
1
当我碰到这个问题来了,这里是我使用的解决方案(在评论简要说明):
RewriteEngine On
RewriteBase/
# do not redirect when using your IP if necessary
# edit to match your IP
RewriteCond %{REMOTE_ADDR} !^1\.1\.1\.1
# do not redirect certain file types if necessary
# edit to match the file types needed
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css)
# this holding page that will be shown while offline
RewriteCond %{REQUEST_URI} !^/offline\.html$
# use 503 redirect code during the maintenance job
RewriteRule ^(.*)$ /offline.html [R=503,L]
ErrorDocument 503 /offline.html
# bots should retry accessing your page after x seconds
# edit to match your maintenance window
Header always set Retry-After "3600"
# disable caching
Header Set Cache-Control "max-age=0, no-cache, no-store"
除了附加条件和标题,主要想法是使用503
状态代码当您正在执行维护工作。
503
代码代表Service Unavailable
,在维护过程中就是这种情况。使用此功能也会对搜索引擎优化很有帮助,因为漫游器不会为503
网页编制索引,而且它们会在指定的Retry-After
后面再回来查找实际内容。
这里了解更多详细信息:
- 使用503 HTTP状态代码(从谁在谷歌工作过的人) - 使用Apache和.htaccess的https://plus.google.com/+PierreFar/posts/Gas8vjZ5fmB
- 重定向网站以维护页 - http://www.shellhacks.com/en/Redirect-Site-to-Maintenance-Page-using-Apache-and-HTAccess
- HTTP 503:正确处理网站维护搜索引擎优化 - https://yoast.com/http-503-site-maintenance-seo/
相关问题
- 1. htaccess将所有页面重定向到一个页面
- 2. 使用htaccess将所有部分页面重定向到一页
- 3. 将所有页面请求重定向到一个页面
- 4. 用htaccess将所有内容重定向到一个页面
- 5. .htaccess将所有流量重定向到一个页面(410 Gone)
- 6. 将一个php页面重定向到Apache的html页面htaccess
- 7. 如何使用.htaccess将一个aspx页面重定向到一个php页面?
- 8. htaccess如何将目录中的所有页面重定向到索引页面
- 9. 将所有流量重定向到保留页面,除非使用.htaccess登录
- 10. 如何将所有* .html页面重定向到* .php页面?
- 11. 如何使用htaccess将所有页面重定向到404
- 12. htaccess - 重定向到另一个页面
- 13. 的.htaccess重定向到一个页面
- 14. 如何将一个子域的所有页面重定向到附加页面?
- 15. 重定向的所有页面,除了一个页面到子域名的htaccess
- 16. 使用htaccess重定向所有页面
- 17. htaccess rewriterule将每一页重定向到一个页面
- 18. htaccess的重定向所有,但一个页面的HTML到PHP
- 19. .htaccess重定向所有页面到一个域
- 20. .htaccess将2个http页面重定向到https页面
- 21. Htaccess:将一些页面从一个页面重定向到另一个
- 22. 将所有页面重定向到另一个网站上的一个页面
- 23. 如何通过htaccess将index.php重定向到另一个页面
- 24. .htaccess 301将页面重定向到一个PHP页面没有扩展
- 25. 所有页面重定向到主页
- 26. htaccess将特定页面的特定页面重定向到特定页面
- 27. htaccess将特定页面的特定页面重定向到特定页面
- 28. 将所有页面重定向到同一个域上的单个页面
- 29. 将所有页面重定向到顶层页面
- 30. 将所有子域页面重定向到域页面
+1,但在这种情况下,我会使用临时重定向:[R = 307,L] – Piskvor 2010-03-02 09:23:26
@皮克沃尔 - 出色的建议,编辑于! – 2010-03-02 09:25:34
这是给我一个内部服务器错误? – stef 2010-03-03 14:23:31