如何暂时关闭静态页面?

时间:2022-12-31 00:40:08

I have a static web page that I need to turn off, I don't want to delete the file though because there is a good chance I will need to turn it back on in the future. How can I do this?

我有一个静态网页,我需要关闭,我不想删除该文件,因为我很有可能将来需要重新打开它。我怎样才能做到这一点?

Thanks!

5 个解决方案

#1


If the page you are wanting to temporarily 'hide' is a php page, you could do something like this at the top of that php file you want to 'hide'.

如果你想暂时“隐藏”的页面是一个php页面,你可以在你想要“隐藏”的那个php文件的顶部做这样的事情。

<?php 
header('Location: http://www.example.com/not_available.html');
die();
?> 

Just replace the url after Location: to a placeholder page of your choosing.

只需将位置后的网址替换为您选择的占位符页面即可。

There are other HTTP header tricks you could do, like returning a 404, 503, etc.

您可以执行其他HTTP标头技巧,例如返回404,503等。

http://phpweby.com/tutorials/php/35

You could also use the .htaccess trick suggested by @andrew-g-johnson, using the .htaccess file shouldn't have much of an impact performance wise, especially compared to doing it inside PHP.

你也可以使用@ andrew-g-johnson建议的.htaccess技巧,使用.htaccess文件不应该对性能产生很大的影响,特别是与PHP内部相比。

#2


You can use an .htaccess file to redirect it:

您可以使用.htaccess文件重定向它:

rewriteengine on
rewriterule ^static-page.html$ relocate-here.html [L]

#3


You should be having it in your source control(?) then remove it and add it when you need it. Or Rename it as Rob said.

您应该在源代码管理中使用它(?)然后将其删除并在需要时添加它。或者重命名为Rob说。

#4


If you want the page to no longer be served, why not just rename it to file.html.disabled or something? When you want to continue serving it again, rename it back?

如果您希望不再提供该页面,为什么不将其重命名为file.html.disabled或其他内容?如果要再次继续提供服务,请将其重命名?

#5


Rename / move it to a filename/folder that the web server will not serve (good point Richard)

将其重命名/移动到Web服务器无法提供的文件名/文件夹(优点Richard)

#1


If the page you are wanting to temporarily 'hide' is a php page, you could do something like this at the top of that php file you want to 'hide'.

如果你想暂时“隐藏”的页面是一个php页面,你可以在你想要“隐藏”的那个php文件的顶部做这样的事情。

<?php 
header('Location: http://www.example.com/not_available.html');
die();
?> 

Just replace the url after Location: to a placeholder page of your choosing.

只需将位置后的网址替换为您选择的占位符页面即可。

There are other HTTP header tricks you could do, like returning a 404, 503, etc.

您可以执行其他HTTP标头技巧,例如返回404,503等。

http://phpweby.com/tutorials/php/35

You could also use the .htaccess trick suggested by @andrew-g-johnson, using the .htaccess file shouldn't have much of an impact performance wise, especially compared to doing it inside PHP.

你也可以使用@ andrew-g-johnson建议的.htaccess技巧,使用.htaccess文件不应该对性能产生很大的影响,特别是与PHP内部相比。

#2


You can use an .htaccess file to redirect it:

您可以使用.htaccess文件重定向它:

rewriteengine on
rewriterule ^static-page.html$ relocate-here.html [L]

#3


You should be having it in your source control(?) then remove it and add it when you need it. Or Rename it as Rob said.

您应该在源代码管理中使用它(?)然后将其删除并在需要时添加它。或者重命名为Rob说。

#4


If you want the page to no longer be served, why not just rename it to file.html.disabled or something? When you want to continue serving it again, rename it back?

如果您希望不再提供该页面,为什么不将其重命名为file.html.disabled或其他内容?如果要再次继续提供服务,请将其重命名?

#5


Rename / move it to a filename/folder that the web server will not serve (good point Richard)

将其重命名/移动到Web服务器无法提供的文件名/文件夹(优点Richard)