homepage Welcome to WebmasterWorld Guest from 54.197.183.230
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect not removing the query string
We have old URLS that we are redirecting, however
acimag

5+ Year Member



 
Msg#: 4010782 posted 1:38 pm on Oct 21, 2009 (gmt 0)

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

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



 
Msg#: 4010782 posted 4:36 pm on Oct 21, 2009 (gmt 0)

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

5+ Year Member



 
Msg#: 4010782 posted 7:00 pm on Oct 21, 2009 (gmt 0)

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

5+ Year Member



 
Msg#: 4010782 posted 7:00 pm on Oct 21, 2009 (gmt 0)

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

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



 
Msg#: 4010782 posted 9:34 pm on Oct 21, 2009 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved