Rewrite Rule looping error

Hi,

I have a domain "test.example.com" and i wanted to redirect only request like "test.example.com /index.html" to "test.example.com/index.html?NEW=1". Please note that a extra string "?NEW=1" added at the end of the URL.

So Request for http://test.example.com/index.html REDIRECTS TO http://test.example.com/index.html?NEW=1

Below rule endup with looping error.

Rules
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test\.example\.com$
RewriteRule ^index.html$ /index.html?NEW=1 [L]

Please guide me on rewrite rule. Thanks in advance

Regards
Wintech

Not sure, but you added a slash as well as a ?NEW=1

Apache mod_rewrite Introduction - Apache HTTP Server

Hi,

Can anybody help me on this please?

Regards
Paulwintech

Hi,

Can anybody help me on this rewrite rule looping error.....

Regards
Paulwintech

Have you tried his suggestion? In what way did it not work? Any more information you can provide may be helpful. Pointless "please help me" posts on the other hand are not helpful.

Corona688, Yes i tried his suggestion by trying the below Rewrite rule option, but endup in endless looping error

RewriteEngine on
RewriteCond %{QUERY_STRING) !NEW
RewriteRule .* index.html?NEW=1 [L]

---------- Post updated at 01:42 AM ---------- Previous update was at 01:11 AM ----------

Hi Corona688,

Any luck? for my rewrite query please!!!

Regards
Paulwintech

You have acrued so many infractions in such a short amount of time that one more will set you read-only for several weeks.

I was out of the office, bumping didn't help me answer faster.

If we don't answer immediately, wait! We are not "on-call". At the very least, post something you tried which didn't work and it's effects. Any more useless "help me" posts will get you banned.

Looking now.

I couldn't get a rewrite-loop with your version. Perhaps your apache configuration is different. But try this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index\.html$ index.html?NEW=1

It will rewrite it only when the query string is blank.

Hi Corona688,

Sorry for the inconvenience caused, I tried ur rule and my page was not redirecting. And my previous rule causing the infinite looping\(Attached a screenshot for your reference\)

I tried in google chrome to make sure its not a browser issue - No luck same looping error....

Im using version: Apache/2.2.3 linux
OS Centos 5.7 (Final) 32 bit

Regards
Paulwintech

That's because it's not a redirect. It's a rewrite. Your browser asks for index.html and gets handed index.html?NEW=1. It doesn't actually tell your browser about it.

Perhaps something in your webpage -- which I'm assuming is actually a CGI script since it takes GET requests -- is causing the redirect.

  • How to redirect the page... Is there any other option to make apache to redirect the page? rather then rewrite

  • Im not using any CGI script for GET request in server

Sorry if my above questions is silly....

Regards
Paulwintech

If nothing cares whether you make a GET request or not, why bother adding ?NEW=1 ? :confused: You don't actually have a file named index.html?NEW=1 do you? That's not going to work, the web browser considers everything after the ? as the query string for a GET request.

You really, really ought to figure out what's redirecting your webpage in the first place before you try redirecting the redirected redirect! You're just going to put a redirection loop inside a redirection loop...

With rewrite rules in sendmail and apparently Apache, sometimes you need to go somewhere else to avoid looping rule 1, and use rule 2 to come back. Good luck.