Forum Moderators: phranque

Message Too Old, No Replies

Please Help! redirect 301 from dynamic URL (.asp?) to static php

301 redirect from dynamic URL (.asp?) to static php

         

pedroh

5:56 am on Nov 22, 2011 (gmt 0)

10+ Year Member



Hello all,

I tried following suggestions from some tutorials but I could find the solution to redirect dynamic URL from the OLD site(asp) to the new site with static URL

example:

Old dynamic URL = [mysite.gov...]

New static URL = [mysite.gov...]

I tried this RewriteCond but it didn't work

RewriteCond %{QUERY_STRING} ^art_id=61$ [NC]
RewriteRule desarrollo/mantenedores/art_indice.asp [mysite.gov...] [R=301,L]

please help!

Thanks,

Pedro

g1smd

7:41 am on Nov 22, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use example.com in this forum to stop URL auto-linking.

What does not work? In what way?

If the new URLs are rewritten, you need to test THE_REQUEST, not QUERY_STRING otherwise you will have an infinite redirect-rewrite loop.

pedroh

4:38 pm on Nov 22, 2011 (gmt 0)

10+ Year Member



Thank you for the quick response..

Here is the case

Old URL = http://example.com/desarrollo/mantenedores/art_indice.asp?art_id=61

New URL = http://example.com/comunidad/articles/2/tipos-de-sociedades

Basically that solution is not redirecting (the one I got from a tutorial).. So I would like to know what should be the right code to be added on .htaccess

Thank you again

lucy24

11:30 pm on Nov 22, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the "art_id=61" always going to be the entire content of your query string? Your RewriteCond is anchored at both ends, so it will fail if there are other queries before and/or after. And, obvious question, do you mean the literal number 61, or any old number?

You also need to allow for percent-encoding: in a query, = might be just that, or it might change to %3D in transit. Similarly the & might come through as %26. This applies to all non-word characters (alphanumerics and _).

pedroh

11:44 pm on Nov 22, 2011 (gmt 0)

10+ Year Member



Hello lucy24, yes "art_id=#" always going to be the entire content of the query string and the number indicates the article or post. I have 550 numbers or post (art_id=1 to art_id=556) that need to be redirected to their new individual URL..

Note: the old URLs were deleted when we moved from an ASP website to PHP site (New URL) same domain name