Question about QUERY_STRING redirects with mod_rewrite

--0016e65b61cc05822f047f2f88b2
Content-Type: text/plain; charset=UTF-8

Hi,

I'm trying to do 301 redirects from a website which used queries extensively
but doesn't use any now. I found this piece of code but it doesn't seem to
work.

RewriteEngine on

RewriteCond %{QUERY_STRING} ^id=13$

RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]


All the examples I found are very similar to this one but I can't get any of
them to work, it simply keeps the ?id=13 part and doesn't rewrite the url.
Am I doing anything wrong or has something changed from one mod_rewrite
revision to another?

Best regards,
Tiago Marques

--0016e65b61cc05822f047f2f88b2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div>Hi,</div><div><br></div><div>I'm trying to do 301 redirects from a=
website which used queries extensively but doesn't use any now. I foun=
d this piece of code but it doesn't seem to work.</div><div><br></div>

<blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0=
px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-=
left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex=
; ">

RewriteEngine on=C2=A0</blockquote><blockquote class=3D"gmail_quote" style=
=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.=
8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-=
left-style: solid; padding-left: 1ex; ">

RewriteCond %{QUERY_STRING} ^id=3D13$</blockquote><blockquote class=3D"gmai=
l_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; m=
argin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204,=
204); border-left-style: solid; padding-left: 1ex; ">

RewriteRule ^/page.php$ <a href=3D"http://www.example.com/newname.htm">http=
://www.example.com/newname.htm</a>? [L,R=3D301]</blockquote><div><br></div>=
<div>All the examples I found are very similar to this one but I can't =
get any of them to work, it simply keeps the ?id=3D13 part and doesn't =
rewrite the url.</div>

<div>Am I doing anything wrong or has something changed from one mod_rewrit=
e revision to another?</div><div><br></div><div>Best regards,</div><div>Tia=
go Marques</div>

--0016e65b61cc05822f047f2f88b2--
Tiago Marques [ Di, 09 Februar 2010 20:00 ] [ ID #2031719 ]

Re: Question about QUERY_STRING redirects with

On Tue, Feb 9, 2010 at 2:00 PM, Tiago Marques <tiagomnm [at] gmail.com> wrote:
> Hi,
> I'm trying to do 301 redirects from a website which used queries extensively
> but doesn't use any now. I found this piece of code but it doesn't seem to
> work.
>>
>> RewriteEngine on
>>
>> RewriteCond %{QUERY_STRING} ^id=13$
>>
>> RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
>
> All the examples I found are very similar to this one but I can't get any of
> them to work, it simply keeps the ?id=13 part and doesn't rewrite the url.
> Am I doing anything wrong or has something changed from one mod_rewrite
> revision to another?

If it's not doing anything, maybe you put them in the wrong VirtualHost?

If you put it in .htaccess, the RewriteRule will never match due to
only matching a leading slash -- those are never present in
per-directory context. You'd also need to make sure AllowOverride was
set for that Directory.


--
Eric Covener
covener [at] gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Eric Covener [ Di, 09 Februar 2010 20:10 ] [ ID #2031720 ]

Re: Question about QUERY_STRING redirects with

--001636416dfbf99d11047f2fcf56
Content-Type: text/plain; charset=UTF-8

On Tue, Feb 9, 2010 at 7:10 PM, Eric Covener <covener [at] gmail.com> wrote:

> On Tue, Feb 9, 2010 at 2:00 PM, Tiago Marques <tiagomnm [at] gmail.com> wrote:
> > Hi,
> > I'm trying to do 301 redirects from a website which used queries
> extensively
> > but doesn't use any now. I found this piece of code but it doesn't seem
> to
> > work.
> >>
> >> RewriteEngine on
> >>
> >> RewriteCond %{QUERY_STRING} ^id=13$
> >>
> >> RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
> >
> > All the examples I found are very similar to this one but I can't get any
> of
> > them to work, it simply keeps the ?id=13 part and doesn't rewrite the
> url.
> > Am I doing anything wrong or has something changed from one mod_rewrite
> > revision to another?
>
> If it's not doing anything, maybe you put them in the wrong VirtualHost?
>
> If you put it in .htaccess, the RewriteRule will never match due to
> only matching a leading slash -- those are never present in
> per-directory context. You'd also need to make sure AllowOverride was
> set for that Directory.
>
>
It was in the .htaccess. You were absolutely right, with the leading slash
removed it works great. I'm not using "AllowOverride" though, will I have
any problem because of it?
Thank you for helping out.

Best regards


>
> --
> Eric Covener
> covener [at] gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
> " from the digest: users-digest-unsubscribe [at] httpd.apache.org
> For additional commands, e-mail: users-help [at] httpd.apache.org
>
>

--001636416dfbf99d11047f2fcf56
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div class=3D"gmail_quote">On Tue, Feb 9, 2010 at 7:10 PM, Eric Covener <sp=
an dir=3D"ltr"><<a href=3D"mailto:covener [at] gmail.com">covener [at] gmail.com</=
a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class=3D"h5">On Tue, Feb 9, 2010 at 2:00 PM, Tiago Mar=
ques <<a href=3D"mailto:tiagomnm [at] gmail.com">tiagomnm [at] gmail.com</a>> w=
rote:<br>
> Hi,<br>
> I'm trying to do 301 redirects from a website which used queries e=
xtensively<br>
> but doesn't use any now. I found this piece of code but it doesn&#=
39;t seem to<br>
> work.<br>
>><br>
>> RewriteEngine on<br>
>><br>
>> RewriteCond %{QUERY_STRING} ^id=3D13$<br>
>><br>
>> RewriteRule ^/page.php$ <a href=3D"http://www.example.com/newname.=
htm" target=3D"_blank">http://www.example.com/newname.htm</a>? [L,R=3D301]<=
br>
><br>
> All the examples I found are very similar to this one but I can't =
get any of<br>
> them to work, it simply keeps the ?id=3D13 part and doesn't rewrit=
e the url.<br>
> Am I doing anything wrong or has something changed from one mod_rewrit=
e<br>
> revision to another?<br>
<br>
</div></div>If it's not doing anything, maybe you put them in the wrong=
VirtualHost?<br>
<br>
If you put it in .htaccess, the RewriteRule will never match due to<br>
only matching a leading slash -- those are never present in<br>
per-directory context. =C2=A0You'd also need to make sure AllowOverride=
was<br>
set for that Directory.<br>
<br></blockquote><div><br></div><div>It was in the .htaccess. You were abso=
lutely right, with the leading slash removed it works great. I'm not us=
ing "AllowOverride" though, will I have any problem because of it=
?</div>

<div>Thank you for helping out.</div><div><br></div><div>Best regards</div>=
<div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
--<br>
Eric Covener<br>
<a href=3D"mailto:covener [at] gmail.com">covener [at] gmail.com</a><br>
<br>
------------------------------------------------------------ ---------<br>
The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL:<a href=3D"http://httpd.apache.org/userslist.html" target=3D"_b=
lank">http://httpd.apache.org/userslist.html</a>> for more info.<br>
To unsubscribe, e-mail: <a href=3D"mailto:users-unsubscribe [at] httpd.apache.or=
g">users-unsubscribe [at] httpd.apache.org</a><br>
=C2=A0 " =C2=A0 from the digest: <a href=3D"mailto:users-digest-unsub=
scribe [at] httpd.apache.org">users-digest-unsubscribe [at] httpd.apac he.org</a><br>
For additional commands, e-mail: <a href=3D"mailto:users-help [at] httpd.apache.=
org">users-help [at] httpd.apache.org</a><br>
<br>
</blockquote></div><br>

--001636416dfbf99d11047f2fcf56--
Tiago Marques [ Di, 09 Februar 2010 20:20 ] [ ID #2031721 ]
Webserver » gmane.comp.apache.user » Question about QUERY_STRING redirects with mod_rewrite

Vorheriges Thema: Malformed host header due to scope-id in IPv6 link-local address
Nächstes Thema: proxy chaining to squid