.ht访问两个站点

发布于 2024-09-18 16:48:12 字数 571 浏览 1 评论 0原文

我有两个站点在同一个域中运行(相同的站点,但旧的 WordPress 和新的自定义)

我需要做:

如果客户端请求存在的文件,那么他可以看到它:(这有效)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

任何其他请求转到index.php

 RewriteRule . /index.php [L]

好的...但是如果您请求/(www.site.com),您将被重定向到www.site.com/site2,而不会经过index.php

我该如何实现这一点? 伪代码(英语不好,抱歉)

if(request == "/" || request == www.site.com) {
    redirect site2/
} else if(ask_for_a_file_that_exists) {
    server file
} else {
    use old index.php
}

I have two sites running in the same domain (the same sites, but the old in wordpress and the new custom)

I need to do:

If the client ask for a file that exists, then he can see it: (this works)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Any other request goes to index.php

 RewriteRule . /index.php [L]

Ok... but if you ask for / (www.site.com) you will have be redirected to www.site.com/site2 without going trough index.php

how can I achieve this?
in pseudocode (bad english, sorry)

if(request == "/" || request == www.site.com) {
    redirect site2/
} else if(ask_for_a_file_that_exists) {
    server file
} else {
    use old index.php
}

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

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

发布评论

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

评论(1

百思不得你姐 2024-09-25 16:48:12

像这样的东西应该有效:

# Check if the request was for the root, and if so, redirect
# internally to the site2 folder
RewriteRule ^$ /site2/ [L]

# Otherwise, let the existing site take care of the rest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Something like this should work:

# Check if the request was for the root, and if so, redirect
# internally to the site2 folder
RewriteRule ^$ /site2/ [L]

# Otherwise, let the existing site take care of the rest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文