在apache中创建一个不重定向的重写查询字符串

时间:2022-04-15 14:58:25

I would like to redirect all the traffic from subdomain.domain.com to subdomain.domain.com/?appselect=app1.

我想将所有流量从subdomain.domain.com重定向到subdomain.domain.com/?appselect=app1。

I followed some of the examples here: Rewrite query string in .htaccess But they are not working for me for some reason. This is what I have so far:

我在这里遵循了一些例子:在.htaccess中重写查询字符串但是由于某些原因它们并不适合我。这是我到目前为止:

RewriteEngine On
RewriteRule ^/$ /?appselect=app1 [PT,L]

But it just goes to the same page: subdomain.domain.com

但它只是转到同一页面:subdomain.domain.com

Any help on this would be appreciated, thanks.

任何有关这方面的帮助将不胜感激,谢谢。

3 个解决方案

#1


If you want redirect then add R flag:

如果要重定向,则添加R标志:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteCond %{QUERY_STRING} !(^|&)appselect=app1 [NC]
RewriteRule ^/?$ /?appselect=app1 [QSA,L,R=302]

#2


Basically doing something like this would work. It worked for my server.

基本上做这样的事情会起作用。它适用于我的服务器。

RewriteEngine On

RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule ^/?$ /?appselect=app1 [QSA,L,R=302]

#3


try

RewriteRule ^$ /?appselect=app1 [PT,L]

#1


If you want redirect then add R flag:

如果要重定向,则添加R标志:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteCond %{QUERY_STRING} !(^|&)appselect=app1 [NC]
RewriteRule ^/?$ /?appselect=app1 [QSA,L,R=302]

#2


Basically doing something like this would work. It worked for my server.

基本上做这样的事情会起作用。它适用于我的服务器。

RewriteEngine On

RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteRule ^/?$ /?appselect=app1 [QSA,L,R=302]

#3


try

RewriteRule ^$ /?appselect=app1 [PT,L]