Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

I want to redirect all traffic to new URL which is mysite.com/mypage.html, but my redirect in .htaccess file doesn't work. Maybe someone can help me with the line of code in .htaccess file. I tried following but it didn't work:

Redirect 301 /?page_id=1103 http://mysite.com/mypage.html
share|improve this question

Here is an article that answers your question:

Unfortunately, neither Redirect nor RedirectMatch allow you to specify a query string for the redirect source. It other words, the following statements are invalid and they will simply be ignored.

Redirect /page.php?id=3  http://mydomain.site/page/3
Redirect /page.php?id=4  http://mydomain.site/page/4

RedirectMatch ^/page.php?id=([0-9]*)$  http://mydomain.site/page/$1

The solution requires to change the focus from mod_alias to mod_rewrite. Here’s an example.

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/page\.php$
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^(.*)$ http://mydomain.site/page/%1.pdf [R=302,L]

So in your case the code should be:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/$
RewriteCond %{QUERY_STRING} ^page_id=1103$
RewriteRule .* http://mydomain.site/mypage.html [R=301,L]
share|improve this answer
I am searching web for 5 hours now to get mod_rewrite working for me, and now I am a bit confused because I couldn't figure out the exact code. Could you show exact code in my case please? – user2161017 Nov 14 '13 at 12:08
I added that to my answer – Stephen Ostermiller Nov 14 '13 at 12:15
Thank you very much. It works as charm. – user2161017 Nov 14 '13 at 12:27
@user2161017, it would be nice to mark it as solved. Also friendly for others to find easy and fast solutions like you and me. – Charles Nov 15 '13 at 5:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.