Create a rewrite query string in apache that is not redirected

I would like to redirect all traffic from subdomain.domain.com

to subdomain.domain.com/?appselect=app1

.

I followed some examples here: Rewrite query string in .htaccess But they somehow don't work for me. This is what I have so far:

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

      

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

Any help on this would be appreciated, thanks.

+3


source to share


3 answers


If you want to redirect add a flag R

:



RewriteEngine On

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

      

+1


source


Basically, something like this will work. It worked on my server.



RewriteEngine On

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

      

+1


source


try

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

      

0


source







All Articles