将带有查询字符串的 URL 重定向到子域,维护查询

发布于 2024-12-28 22:26:33 字数 1372 浏览 1 评论 0原文

我安装了运行 Web 服务的 Drupal 6。因此,如果有人访问 www.example.com/services/json?method=views.get&view_name="test",他们会得到正确的编码响应。

我正在对其进行一些维护工作,因此我创建了一个子域并将所有内容复制到其中,并且我想在处理主域时将所有请求重定向到子域。因此,当请求进来时,它现在需要转到 old.example.com/services/json?method=views.get 等。

我尝试了几种方法,但没有任何效果。它只是变得疯狂,说我有太多重定向,然后页面无法加载。

我尝试过的一些事情:

RedirectMatch 301 /services/json(.*)$ http://old.example.com/services/json$1

或者

RedirectMatch 301 ^/services/json(.*)$ http://old.example.com/services/json$1

这是文件夹结构的外观。

public_html - 顶部文件夹,其中包含以下内容: -主 drupal 站点文件以及我正在编辑的 .htaccess 文件 -old(这是包含子域文件的文件夹,主站点的副本,减去其 .htaccess 文件中的一些内容)

我怀疑该结构可能与它有关,但我不知道。

编辑:有关 .htaccess 文件中的重定向规则的更多信息。

顶级主域文件夹:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RedirectMatch 301 ^/services/json(.*)$ http://old.example.com/services/json$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

在子域文件夹中(我在测试期间删除了大多数其他规则):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

感谢任何帮助。谢谢!

I have a Drupal 6 installation that runs web services. So if someone goes to www.example.com/services/json?method=views.get&view_name="test", they get the proper encoded response.

I'm doing some maintenance work on it, so I created a sub-domain and copied everything over to it, and I want to redirect all requests to the subdomain while the main one is being worked on. So when a request comes in, it now needs to go to old.example.com/services/json?method=views.get, etc.

I've tried a few ways, but nothing works. It just goes crazy, saying I have too many redirects and then the page fails to load.

A few things I've tried:

RedirectMatch 301 /services/json(.*)$ http://old.example.com/services/json$1

Or

RedirectMatch 301 ^/services/json(.*)$ http://old.example.com/services/json$1

Here is how the folder structure looks.

public_html - top folder with the following inside it:
-main drupal site files with the .htaccess file I'm editing
-old (this is the folder that contains the subdomain files, a copy of the main site, minus some stuff on its .htaccess file)

I suspect that structure might have something to do with it, but I have no idea.

EDIT: More info about what redirect rules are in the .htaccess files.

Top main domain folder:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RedirectMatch 301 ^/services/json(.*)$ http://old.example.com/services/json$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

In the subdomain folder (I've removed most of the other rules during my testing):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Any help is appreciated. Thanks!

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

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

发布评论

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

评论(1

未蓝澄海的烟 2025-01-04 22:26:33

您确定您的 .htaccess 文件/Apache 配置不会影响子域吗?进入子域的请求也将与您的重定向匹配,并创建该循环。

Are you sure your .htaccess file / Apache config isn't also affecting the subdomain? Requests that come in on the subdomain would match your redirect, as well, and create that loop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文