Re: Mod_rewrite too many redirects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 24, 2022 at 8:09 AM vicky chb <vkychb04@xxxxxxxxx> wrote:
>
> Hi,
>
> I am trying to achieve below redirection rule:
> http://localhost/?1234ab
> this url should be redirected to below url:
> http://localhost/welcome?trackFor=0&trackNo=1234ab
> (where welcome?trackFor=0trackNo= always remains same)
>
> Here you can see at the end, the query string is passed same as in source url i.e. 1234ab
>
> I wrote the below Rewrite rule and condition:
>
>  <IfModule mod_rewrite.c>
>  RewriteEngine On
>  RewriteCond %{QUERY_STRING} (.*(([0-9]+).*)) [NC]
>  RewriteRule ^(.*)$ /welcome?trackFor=0&trackNo=%1 [L,R=302,QSD]
>  </IfModule>
>
> When I hit the source URL in browser: http://localhost/?1234ab
>
> I receive, too many redirects error in browser and page keeps on loading.
>
> Am I missing something in mod_rewrite?

The rule matches the target of the redirect, so it will loop.
If the rule is only valid for requests to "/?:

If the rule is in virtual host context
RewriteRule ^/$ /welcome?trackFor=0&trackNo=%1 [L,R=302,QSD]
If the rule is in htaccess, location, or other sections:
RewriteRule ^$ /welcome?trackFor=0&trackNo=%1 [L,R=302,QSD]

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux