重定向除“测试版”之外的所有流量子域到启动屏幕 (mod_rewrite)

发布于 2024-09-02 14:49:50 字数 1007 浏览 1 评论 0原文

我想将所有流量重定向到我的根域,根域是启动画面。我只想在 %{HTTP_HOST} 不是 beta.example.(com|es|fr) 时执行此操作。

所以我在我的 .htaccess 文件中尝试了以下内容,但没有运气...(无限循环...我猜它没有得到 REQUEST_URI 条件,但无法弄清楚为什么?我几乎尝试了所有方法

RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule ^.*$ / [NC,L,R=302]

)一点,我应该将除“beta”子域之外的所有流量重定向到根域。所以现在我想用我的启动屏幕重写“后台”根域,遵循 .htaccess 文件:

RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ splash.phtml [NC,L]

注意:我使用的是 Zend Framework,所以这些规则遵循 .htaccess 文件:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我必须说,我被困住了。

提前谢谢

I'd like to redirect all my traffic to my root domain, the root domain being a Splash screen. I'd like to do this ONLY when the %{HTTP_HOST} is not beta.example.(com|es|fr).

So I've tried the following in my .htaccess file, with no luck... (infinite loop... I guess it's not getting the REQUEST_URI condition, but cannot figure out why?? I've tried almost everything)

RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule ^.*$ / [NC,L,R=302]

At that point, I should have all my traffic but "beta" sub-domain redirected to the root domain. So now I'd like to Rewrite "backstage" the root domain with my Splash screen, following in the .htaccess file:

RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ splash.phtml [NC,L]

Note: I'm using the Zend Framework, so these rules are following in the .htaccess file:

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

I must say, I'm stuck.

thx in advance

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

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

发布评论

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

评论(1

苏大泽ㄣ 2024-09-09 14:49:50

@bsagols

Zend 的这句话肯定会把你搞砸。

RewriteRule ^.*$ index.php [NC,L]

您需要将指令放在此之上(如果不是放在所有 Zend 内容之上的话)。如果我理解正确,请尝试以下操作:

RewriteCond "%{HTTP_HOST}"   "!^beta\.example\.(com|es|fr)$"    [NC]
RewriteCond "%{REQUEST_URI}" "!\.(js|ico|txt|gif|jpg|png|css)$" [NC]
RewriteRule ".*"              "/splash.phtml"                   [R=302,L]

@bsagols

This line from Zend is going to screw you up for sure.

RewriteRule ^.*$ index.php [NC,L]

You need to put your directives above this, if not above all of the Zend stuff. If I'm understanding you correctly, try this:

RewriteCond "%{HTTP_HOST}"   "!^beta\.example\.(com|es|fr)$"    [NC]
RewriteCond "%{REQUEST_URI}" "!\.(js|ico|txt|gif|jpg|png|css)$" [NC]
RewriteRule ".*"              "/splash.phtml"                   [R=302,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文