问题描述
首先,我知道有上的.htaccess设置相当多的职位,但我看不到一个一致的答案,所以我不知道什么是最好的办法。所以请裸陪我,如果我重复的东西从其他地方。
First, I realise there are quite a few posts on .htaccess settings but I can't see a consistent answer so I'm wondering what is the best approach. So please bare with me if I'm repeating something from elsewhere.
我在执行更新到网站,所以我想创建一个302临时重定向,除了一个特定页面的所有网页。
易腐press.com对的,我现在使用的选项1的话题两篇文章:
perishablepress.com has two articles on the topic for which I am currently using option 1:
- http://perishablepress.com/temporary-site-redirect-for-visitors-during-site-updates/
- http://perishablepress.com/htaccess-redirect-maintenance-page-site-updates/
这些物品是指修改的所有页面,在这里我有一个网页我想保持住。 (因为它的推移,我努力让选项2,在所有的工作)。谁能告诉我什么是实现这一目标的最佳途径?
These article refer to amending all pages, where as I have one page I want to keep live. (As it goes I'm struggling to get option 2 to work at all). Can anyone tell me what is the best way to achieve this?
要澄清,我想:
- 拥有的所有页面重定向到
即将-soon.html
(即 www.mywebsite.com/sample-page.html 的=> www.mywebsite.com/coming-soon.html 的) - 添加例外
/contact-us.html
使这一请求被正常处理(即www.mywebsite.com/contact-us html的
=>的 www.mywebsite.com/contact-us.html 的)
- Have all pages redirect to
coming-soon.html
(i.e. www.mywebsite.com/sample-page.html => www.mywebsite.com/coming-soon.html) - Add an exception for
/contact-us.html
so that this request is processed normally (i.e.www.mywebsite.com/contact-us.html
=> www.mywebsite.com/contact-us.html)
感谢您的帮助,我是相当新的的.htaccess!
Thanks for any help, I'm rather new to .htaccess!
推荐答案
您可以尝试这样的:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !contact-us.html [NC]
RewriteCond %{REQUEST_URI} !coming-soon.html [NC]
RewriteCond %{REQUEST_URI} \.(html|htm)/? [NC]
RewriteRule .* coming-soon.html [R=301,L]
这篇关于最好的办法,为的.htaccess临时重定向(302)与异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!