Forum Moderators: phranque

Message Too Old, No Replies

How do i redirect from dynamic to static content?

         

andymax

5:12 pm on Sep 12, 2010 (gmt 0)

10+ Year Member



How do I redirect something like this:

Redirect 301 /default.aspx?pageId=11 /new_page.html

I'm pretty clueless on this one ...,

:-) Andy

jdMorgan

4:37 pm on Sep 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This only works if you meant what you said in the title: The actual file must be a static HTML file:

RewriteCond %{QUERY_STRING} ^pageId=11$
RewriteRule ^default\.aspx$ http://www.example.com/new_page.html [R=301,L]

Rather than coding a bunch of near-identical rules like this, a more complex but more efficient solution is available if you need to do more than just a handful or redirects.

This code is for use in example.com/.htaccess. This example code also assumes that you already have other working mod_rewrite rules, that you do not mix mod_alias directives like "Redirect 301" with mod_rewrite directives (or that you stop trying to do so, because it can cause big trouble), and that your rules are all in the proper order. For more info, see this thread [webmasterworld.com] in our Library.

Jim