.htaccess 重定向

发布于 2024-09-24 10:25:20 字数 536 浏览 0 评论 0原文

只是想知道是否有人可以帮助我解决以下问题。

我想将我的网站重定向到子域,whishc 只是显示一个维护页面,允许我在主网站上工作。

因此,我的 .htaccess 代码如下:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.co.uk$
RewriteRule ^/?$ "http\:\/\/maintenance\.domain\.co\.uk" [R=301,L]

但是,我需要访问根域才能查看我已完成的工作;但是,我只希望自己在我的 IP 上能够查看该内容,并且外部世界被重定向到显示维护页面的子域。

我本以为下面的代码:

RewriteCond %{REMOTE_HOST} !^00\.000\.00\.000

会允许我这样做;但是,我仍然被重定向到子域,我想知道是否有人可以进一步帮助我。

谢谢

Just wondering if someone can help me with the following issue.

I want to redirect my site to a subdomain, whishc simply displays a maintenace page, allowing me to work on the main site.

So I have the following code for my .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.co.uk$
RewriteRule ^/?$ "http\:\/\/maintenance\.domain\.co\.uk" [R=301,L]

However, I need to access the root domain to be able to view the work that I have done; however, I only want myself on my IP to be able to view that and the outside world is redirected to the subdomain which displays the maintenace page.

I would have thought that the following code:

RewriteCond %{REMOTE_HOST} !^00\.000\.00\.000

Would have allowed me to do that; however, I'm still being redirected to the sub domain and I wondered is someone could assist me further wth this.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈甜 2024-10-01 10:25:20

我相信你最好使用 %{REMOTE_ADDR}

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteCond %{REMOTE_ADDR} !=00.00.00.00
RewriteRule ^/?$ http://maintenance.domain.co.uk/ [R=301,L]

You'd be better of using %{REMOTE_ADDR}, I believe:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteCond %{REMOTE_ADDR} !=00.00.00.00
RewriteRule ^/?$ http://maintenance.domain.co.uk/ [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文