.htaccess htaccess:如何将所有页面重定向到保留页面
我必须把一个网站关闭大约半小时,而我们把第二个服务器到位。使用.htaccess,如何将任何请求重定向到.htaccess htaccess:如何将所有页面重定向到保留页面,.htaccess,.htaccess,我必须把一个网站关闭大约半小时,而我们把第二个服务器到位。使用.htaccess,如何将任何请求重定向到domain.com到domain.com/holding_page.php Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} !/holding_page.php$ RewriteRule $ /holding_page.php$l [R=307,L] 使用307(谢谢!)而不是302-: 请求的资源
domain.com
到domain.com/holding_page.php
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/holding_page.php$
RewriteRule $ /holding_page.php$l [R=307,L]
使用307(谢谢!)而不是302-:
请求的资源驻留在
暂时使用不同的URI。
因为重定向可能会被更改
有时,客户应该
继续使用的请求URI
今后的请求
这个效果更好
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/holding_page.php$
RewriteRule $ /holding_page.php [R=307,L]
当我遇到这个问题时,以下是我使用的解决方案(在评论中简要说明): 除了附加条件和标题外,主要思想是在执行维护工作时使用
503
状态代码
503
代码代表服务不可用
,这正是维护期间的情况。使用此选项也将有利于SEO,因为机器人程序不会为503
页面编制索引,它们将在指定的重试后返回以查找实际内容
请在此处阅读更多详细信息:
- 使用503 HTTP状态代码(来自谷歌工作人员)——
- 使用Apache和HTAccess将站点重定向到维护页面-
- HTTP 503:为SEO正确处理站点维护-
这似乎可以在RewriteCond%{REQUEST\u URI}上运行RewriteEngine/index xtemp.php$RewriteRule$/index xtemp.php[R=307,L]由于这个答案仍然位于搜索结果的顶部,因此添加RewriteCond%{REQUEST\u URI}可能是个好主意。(jpe?g?| png | gif)[NC]
。这将阻止图像突破重定向到保留页。我知道这并不是严格意义上的原始问题的一部分,但仍然很方便。
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"