Apache Server configuration support - Redirects Question

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > February 2006 > Redirects Question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Redirects Question
ndbabb@gmail.com

2006-02-17, 10:29 pm

I am attempting to do a permanent redirect, along the following lines:


From: /folder1/folder2/folder3?val=1
To: /folder1/folder2/folder3


(basically, doing a permanent redirect to the same URL minus the
querystring. For SEO reasons)


The issue i'm having is: "RedirectPermanent" doesn't seem to pay
attention to querystrings. For example, the following does not work:
"RedirectPermanent /folder1/folder2/folder3?val=1
http://www.domain.com/folder1/folder2/folder3"


Also, I've tried using a RewriteCond and RewriteRule, along the
following lines:


RewriteCond %{QUERY_STRING} ^val=1$
RewriteRule ^folder1/folder2/folder3$ /folder1/folder2/folder3
[R=permanent,L]


But it appears the RewriteRule, by default, passes along the
querystring (?val=1). I haven't found any Flags to supress/exclude
passing the querystring.


Any thoughts? Another way to accomplish this?


Thanks in advance!

Robert Ionescu

2006-02-17, 10:29 pm

ndbabb@gmail.com wrote:
> But it appears the RewriteRule, by default, passes along the
> querystring (?val=1)


Exactly. The old QueryString gets passed along to the substitution
unless you specify a new queryString in the substitution.

To erase the queryString: just add a question mark:

RewriteCond %{QUERY_STRING} ^val=1$
RewriteRule ^(folder1/folder2/folder3)$ /$1? [R=301,L]

--
Robert
ndbabb@gmail.com

2006-02-17, 10:29 pm

Works perfectly. Thanks!

2006-02-17, 10:29 pm

In article <1140105229.468377.225680@g44g2000cwa.googlegroups.com>,
<ndbabb@gmail.com> wrote:
>I am attempting to do a permanent redirect, along the following lines:
>
>
>From: /folder1/folder2/folder3?val=1
>To: /folder1/folder2/folder3
>
>
>(basically, doing a permanent redirect to the same URL minus the
>querystring. For SEO reasons)
>
>
>The issue i'm having is: "RedirectPermanent" doesn't seem to pay
>attention to querystrings. For example, the following does not work:
>"RedirectPermanent /folder1/folder2/folder3?val=1
>http://www.domain.com/folder1/folder2/folder3"
>
>
>Also, I've tried using a RewriteCond and RewriteRule, along the
>following lines:
>
>
>RewriteCond %{QUERY_STRING} ^val=1$
>RewriteRule ^folder1/folder2/folder3$ /folder1/folder2/folder3
>[R=permanent,L]



Try this:

[R=permanent,L,QSA]

--
http://www.spinics.net/lists/vfl/
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com