2

I'm trying to redirect a url http://domain.com/?p=106 to http://domain.com/?p=110

My .htaccess file looks like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=106
RewriteRule / http://domain.com/\?p=110 [L,R=301]

But I can't seem to get it to work.

binaryorganic
  • 6,021
  • 4
  • 18
  • 19

2 Answers2

1

RewriteRule / wouldn't match a request to / in htaccess. The path you compare against is empty in that case (the prefix is stripped in htaccess rewriterule)

RewriteRule ^$ http://domain.com/?p=110 
covener
  • 1,685
  • 9
  • 15
1

According to the docs, you need to check that Options FollowSymLinks is enabled before trying rewrite in a .htaccess. Then, you also have to note that the per-directory prefix is automatically removed, which means a pattern with ^/ never matches anything (I bet this is why your / doesn't work).

So, in your case, first check Options FollowSymLinks and then change the RewriteRule to be something as covener suggested, or my version:

RewriteRule ^$ /?p=110
phunehehe
  • 741
  • 2
  • 8
  • 17