Need a help with "mod_rewrite" - redirect dynamic URL to static URL

Discussion in 'Apache' started by mauroo, Nov 14, 2013.

  1. #1
    I transferred my WordPress site to static HTML website, but some other website have a link to my old WordPress site http://mysite.com/?page_id=1103.

    I want to redirect all traffic from that URL to new URL which is http://mysite.com/myfolder/mypage.html, but my redirect in .htaccess file doesn't work (Redirect 301 /?page_id=1234 http://mysite.com/myfolder/mypage.html) because of the query string. Maybe someone can help me with "mod_rewrite" to create the right code in .htaccess file.

    Thanks
     
    mauroo, Nov 14, 2013 IP
  2. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Try to use this code in your .htaccess file:
    RewriteEngine on
    
    RewriteCond %{QUERY_STRING} ^?page_id=1234$ [NC]
    RewriteRule ^/?$ http://mysite.com/myfolder/mypage.html [R]
    Code (markup):
    Or change the value of WordPress Address (URL) or Site Address (URL) on your WP Settings > General to "http://mysite.com/myfolder" or "http://mysite.com/myfolder/".
     
    MBDungo, Nov 14, 2013 IP