Welcome to WebmasterWorld Guest from 54.196.233.239

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect not removing the query string

We have old URLS that we are redirecting, however

     

acimag

1:38 pm on Oct 21, 2009 (gmt 0)

5+ Year Member



It is not removing the Qurery STring.

The original URL that we want to redirect is structured

http://www.example.com/Repair_Service/Repair.php?TOWN=Island_Park

We put in the HTACCESS FILE:

redirect 301 /Computer_Services/PC_Repair.php http://www.example.com/New_York/Long_Island/Repair_Service/New_York_Repair.html

HOWEVER IT LEADS ME TO THE:
http://www.example.com/New_York/Long_Island/Repair_Service/New_York_Repair.html?TOWN=Island_Park

The Ideal redirect would have the link READ:

http://www.example.com/New_York/Long_Island/Repair_Service/Island_Park_Repair.html

How can one go about doing this?

[edited by: jdMorgan at 4:34 pm (utc) on Oct. 21, 2009]
[edit reason] example.com [/edit]

jdMorgan

4:36 pm on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Use mod_rewrite instead of mod_alias, and end the new URLs with a question mark. This is not treated as a literal; it won't appear in the new URL. It is treated as a token indicating that you want to clear the query string.

In mod_rewrite, you must use a RewriteCond to examine/test the query string, if you only want to redirect based on a specific URL+query value. From your mod_alias code above, it appears that you may wish to redirect without regard to the requested query string, so this may not be necessary.

Jim

acimag

7:00 pm on Oct 21, 2009 (gmt 0)

5+ Year Member



I tried writing this with trhe rewrite rule:

RewriteRule ^New_York/Long_Island/Repair_Service/([^/]*)_Repair.html$ [domain.com...] [R=301,L,QSA]

It is not redirecting.

acimag

7:00 pm on Oct 21, 2009 (gmt 0)

5+ Year Member



I tried writing this with trhe rewrite rule:

RewriteRule ^New_York/Long_Island/Repair_Service/([^/]*)_Repair.html$ [domain.com...] [R=301,L,QSA]

It is not redirecting.

jdMorgan

9:34 pm on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The form of the URL-path to be rewritten should be identical to that in your "Redirect" directive above, except that you'll need to remove the leading slash.

So your URL-path-pattern should probably start with "^Computer_Services/" as it did in your original code.

Please do not change the URLs cited here unless the originals were wrong. We need good example URLs, and we need to know where your code is located. If either change, then the code must change.

From the description of your goal, you certainly do not want to use the "QSA" flag...

Also, if you do not have other working rewriterules, you'll need one or two more directives to set up and enable mod_rewrite.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month