htaccess 从domain.com重定向到sub.domain.com,同时保持对文件夹的文件访问

发布于 2024-09-28 16:29:47 字数 280 浏览 1 评论 0原文

我想从 http://domain.com & 重定向网站http:// www.domain.com 到 http://v2.domain.com,同时保持对 http 的访问:// (www.)domain.com/images/*

我尝试了多种方法,但不知何故我无法再访问 /images 文件夹。

PS:子域和子域根目录有不同的内容/CMS。关于如何实现这一点有什么想法吗?

谢谢

I'd like to redirect a website from http:// domain.com & http:// www.domain.com to http://v2.domain.com, while maintaining access to http:// (www.)domain.com/images/*

I've tried several methods but somehow I can no longer access the /images folder anymore.

P.S: both subdomain & root has different content/CMS. Any ideas as to how to implement this?

Thanks

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

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

发布评论

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

评论(2

你又不是我 2024-10-05 16:29:47

您还没有准确解释它们是如何配置的。我假设 www.domain.com 和 v2.domain.com 是不同的虚拟主机:

您​​应该能够在 www.domain 的 .htaccess 文件或 apache 配置中执行此操作。 com:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !images/
RewriteRule ^/(.*)                      http://v2.domain.com/$1 [L,R]

You haven't explained exactly how these are configured. I'm going to assume that www.domain.com and v2.domain.com are different virtual hosts:

You should be able to do this in your .htaccess file or apache configuration for www.domain.com:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !images/
RewriteRule ^/(.*)                      http://v2.domain.com/$1 [L,R]
傲鸠 2024-10-05 16:29:47

我意识到这样的事情也可以起作用。可能需要一些测试,但如果这是错误的,请发表评论。

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{HTTP_HOST} !v2\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://v2.domain.com/ [R=302,L]

I realised something like this could work as well. Probably need some testing, but if this is wrong do comment.

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